title: how to include db config file in respective php files
body: <p>one of my main problems in coding is including config.php  and db class where i need to connect to databse </p>
  
  <p>consider i have a  mysql.php  and config.php  file in root of my files </p>
  
  <p>now if im in this path :</p>
  
  <p>Root/Sub/portal/modules/Gallery.php</p>
  
  <p>and i need to fetch  config.php  vars  such as  </p>
  
  <pre><code>$dbhost = "localhost"; 
  $dbuname = "root";  // Database username
  $dbpass = "";   // Database password
  $dbname = "mydb";   // Database NAME
  </code></pre>
  
  <p>i should include it in this way :</p>
  
  <pre><code>require("../../../config.php");
  require("../../../mysql.php");
  
  $mdb = new sql_db($dbhost, $dbuname, $dbpass, $dbname, false);
  if(!$mdb-&gt;db_connect_id) {
  die("cant connect to db");
  }
  </code></pre>
  
  <p>sure it would give me an error :</p>
  
  <blockquote>
    <p>Warning: include(../../../config.php)
    [function.include]: failed to open
    stream: No such file or directory in</p>
    
    <hr>
  </blockquote>
  
  <p>so is there any way to avoid this error  and find a way to connect to my db ?!</p>