title: Unable to get variables from different files
body: <p>Im trying to get data from my database and echo it with a variable, but I have a problem with that. When I try to get my variables from different files it shows me this error:</p>
  
  <blockquote>
    <p>Undefined variable: con in.</p>
  </blockquote>
  
  <p>Here some codes:</p>
  
  <p>Code from functions.php:</p>
  
  <pre><code>include "authentication.php";
  
  function GetData() {
  $id = session_id();
  $result3 = mysqli_query($con,"SELECT * FROM accounts where id='$id'");
  while($row3 = mysqli_fetch_array($result3));
  { 
  $email=$row3['email'];
  $fullname=$row3['fullname'];
  $usualname=$row3['usualname'];
  $lastname=$row3['lastname'];
  }
  }
  </code></pre>
  
  <p>Code from authentication.php:</p>
  
  <pre><code>$DATABASE_HOST = 'localhost';
  $DATABASE_USER = '***';
  $DATABASE_PASS = '***';
  $DATABASE_NAME = '***';
  
  $con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
  if ( mysqli_connect_errno() ) {
  
      die ('Failed to connect to MySQL: ' . mysqli_connect_error());
  }
  </code></pre>
  
  <p>This also happens when I try to get variables from other files..
  Here you get some screenshots of the error from different files and different variables:</p>
  
  <p><a href="https://i.stack.imgur.com/6RXWh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6RXWh.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/6yNe3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6yNe3.png" alt="enter image description here"></a></p>
  
  <p>Both files are in the same directory called PHPscripts:</p>
  
  <p><a href="https://i.stack.imgur.com/Finjq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Finjq.png" alt="enter image description here"></a></p>