“current directory” notation not working

PrivatePilot198

New Member
I was taught that it's good practice to specify the directory of a file you're linking to, even when the file is in the current directory. So, for example, use "./constants.inc.php" as opposed to "constants.inc.php". This has generally worked fine for me, except in one particular spot in my code I get the following PHP error when I use the ./ notation:\[quote\] Warning: require(./constants.inc.php) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\widget_corp\includes\functions.inc.php on line 4 Fatal error: require() [function.require]: Failed opening required './constants.inc.php' (include_path='.;C:\xampp\php\PEAR;C:\xampp\htdocs\websites\mathverse\includes') in C:\xampp\htdocs\widget_corp\includes\functions.inc.php on line 4\[/quote\]Writing "./constants.inc.php" gives this error, but "constants.inc.php" doesn't (PHP seems to find the file just fine). Can someone tell me why the ./ notation doesn't work in this particular case? Perhaps it's something very simple I'm missing?To give a bit more context (if necessary), the error is in the function below (line 2), which is in my PHP functions file (called functions.inc.php) which is inside an includes directory. The constant.inc.php file is also inside the includes directory.Thank you.\[code\]function connect_to_db() { require("./constants.inc.php"); $connection_id = mysql_connect(DB_SERVER, DB_USER, DB_PASS); if (!$connection_id) { die("Database connection failed: " . mysql_error()); } $db_selection_was_successful = mysql_select_db(DB_NAME, $connection_id); if (!$db_selection_was_successful) { die("Database selection failed: " . mysql_error()); }}\[/code\]
 
Top