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