title: Importing a file with MySQLi functions in PHP breaks calling page
body: <p><strong>main.php</strong></p>
  <p>When importing config.php, clubsData.php, and calling checkEnrollment(), my database $link is undefined. This breaks all queries and outputs warnings such as &quot;mysqli_prepare() expects parameter 1 to be mysqli, null given...&quot;</p>
  <pre><code>session_start();
  require_once($_SERVER['DOCUMENT_ROOT'].&quot;/imports/config.php&quot;);
  require_once($_SERVER['DOCUMENT_ROOT'].&quot;/imports/clubsData.php&quot;);
  checkEnrollment($user_id, $clubid);
  </code></pre>
  <p><strong>config.php</strong></p>
  <pre><code>$DB_SERVER = getenv('DB_HOST');
  $DB_USERNAME = getenv('DB_USER');
  $DB_PASSWORD = getenv('DB_PASSWORD');
  $DB_NAME = getenv('DB_NAME');
  
  $link = mysqli_connect($DB_SERVER, $DB_USERNAME, $DB_PASSWORD, $DB_NAME);
  
  mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
  
  </code></pre>
  <p><strong>clubsData.php</strong></p>
  <pre><code>function checkEnrollment($user_id, $club_id) {
      $sql = &quot;SELECT role FROM in_clubs WHERE user_id = ? AND club_id = ?&quot;;
      $stmt = mysqli_prepare($link, $sql);
      mysqli_stmt_bind_param($stmt, &quot;ss&quot;, $param_user_id, $param_club_id);
      $param_user_id = $user_id;
      $param_club_id = $club_id;
      mysqli_stmt_execute($stmt);
      mysqli_stmt_store_result($stmt);
      mysqli_stmt_fetch($stmt);
      if(mysqli_stmt_num_rows($stmt) == 1){       
          return true;
      } else {
          return false;
      }
      mysqli_stmt_close($stmt);
  }
  </code></pre>