title: PHP using include() variable scope issue
body: <p>I have commonFun.php for commong functions;</p>
  
  <pre><code>&lt;?php
  
  function connectDB(){
      $con = @mysqli_connect( "localhost:3306", "root", "P@ssw0rd", "DogSport" ) or die ("Couldn't connect to server");
  }
  
  //check that email is not already in list
  function emailChecker( $email ){
      connectDB();
  
      $safe_email = mysqli_real_escape_string( $con, $email );
      $check_sql = "SELECT Id FROM Subscribers WHERE Email='". $safe_email. "'";
  
      $result = mysqli_query ( $con, $check_sql ) or die ("Couldn't execute SELECT query: ". mysqli_error($con));
  }
  ?&gt;
  </code></pre>
  
  <p>When I call emailChecker() function from another PHP script, why does $con variable in connectDB() is not available to emailChecker() function? I have already called connectDB() function inside emailChecker() function? What am I doing wrong????? </p>
  
  <p>I get the following errors;</p>
  
  <pre><code> Notice: Undefined variable: con in C:\xampp\htdocs\PHP\commonFun.php on line 11
  
  Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\PHP\commonFun.php on line 11
  
  Notice: Undefined variable: con in C:\xampp\htdocs\PHP\commonFun.php on line 14
  
  Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\PHP\commonFun.php on line 14
  
  Notice: Undefined variable: con in C:\xampp\htdocs\PHP\commonFun.php on line 14
  
  Warning: mysqli_error() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\PHP\commonFun.php on line 14
  Couldn't execute SELECT query:
  </code></pre>