title: Use Require_once() to include database connection variables correctly
body: <p>I'm a php newbie (but long time developer in other languages) and I'm trying some example db connections in "PHP, MySQL, &amp; JavaScript". It shows an example file to include db connection variables (servername, username, password, database, etc.). I have a php file which has a handful of functions I wrote and one of them has a few SQL queries. For whatever reason, calling require_once in that file doesn't output any errors (I have E_ALL config'd) yet those variables in my database php file are null.</p>
  
  <p>I called an echo with all the variables within that function to see what the heck is going on and of course it prints a blank line. What in the world is out of scope? I have to be missing something simple.</p>
  
  <p>Here's an example of what I'm doing</p>
  
  <p><strong>db_login.php</strong></p>
  
  <pre><code>&lt;?php
      $db_server = 'localhost';
      // ....
  ?&gt;
  </code></pre>
  
  <p><strong>functions.php</strong></p>
  
  <pre><code>&lt;?php
      require_once('db_login.php');
  
      function myfunction() {
          echo "$db_server";
          // ...
      }
  ?&gt;
  </code></pre>
  
  <p>Call me crazy, but shouldn't this be simple enough to work?</p>