title: No database selected error only comes up when in a separate included php config file but works when in needed file
body: <p>Basically ive been trying to create a config file so it is much easier to edit the MYSQL connection info to the online database when ive completed my current website. The connection code i have works perfectly when in each file when needed but when i try and use an required once on the same code in a config file it says no database selected. this error never happens when the connection code is pre written into files. here is my config file code and then the working code which is already on a working page.</p>
  
  <p>config php</p>
  
  <pre><code>&lt;?php
  //configures connection to the mysql database.
  $con = mysql_connect("localhost","james");
  if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  
  mysql_select_db("cds", $con);    
  ?&gt;
  </code></pre>
  
  <p>and here is the code on a working connection to the database</p>
  
  <pre><code>&lt;?php
  //configures connection to the mysql database.
  $con = mysql_connect("localhost","root");
  if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  mysql_select_db("cds", $con);
  
  $n = $_SESSION['news'];
  
  // find out how many rows are in the table 
  if($n == 1)
  {
      echo '&lt;h1&gt;CDSRail News&lt;/h1&gt;';
      $sql = 'SELECT COUNT(*) FROM news ORDER BY news_date DESC';
      $query = mysql_query($sql);
      echo "&lt;hr/&gt;Click the links below to view our News&lt;br&gt;&lt;br&gt;";
      $result = mysql_query($sql);
      $r = mysql_fetch_row($result);
      $numrows = $r[0];...
  </code></pre>
  
  <p>please help!!!</p>