EchoFool Posted March 31, 2008 Share Posted March 31, 2008 I keep getting an error with an include of: Warning: include(connect/include.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\css\layout1.php on line 4 Warning: include() [function.include]: Failed opening 'connect/include.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\css\layout1.php on line 4 This is the include causing the error: <?php include("connect/include.php"); This is the include script: <?php ini_set('error_reporting', E_ALL); $connect = mysql_connect("etc etc etc etc"); //error handle if (!$connect) { echo "Unable to connect to DataBase: " . mysql_error(); exit; } //error handle if (!mysql_select_db("dbtest")) { echo "Unable to select database: " . mysql_error(); exit; } If(strtolower($_SERVER['PHP_SELF']) == '/connect/include.php'){ header("location: ../login.php"); die; } ?> Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted March 31, 2008 Share Posted March 31, 2008 are you sure you are calling the right directory? where is the file located that is calling the include? where is the included file located? Quote Link to comment Share on other sites More sharing options...
discomatt Posted March 31, 2008 Share Posted March 31, 2008 The error is pretty self-explanatory Quote Link to comment Share on other sites More sharing options...
EchoFool Posted April 1, 2008 Author Share Posted April 1, 2008 The error is pretty self-explanatory Not really...because i have the directory correct. Anyway, the file that is "Calling" the include is in a folder named "css" So lets say its called page.php so it is here : "/css/page.php" Now page.php needs to include the file : "/connect/include.php" I tried : ../connect/include.php as the "../" brings it back to the root so it can go from there to the folder but no such luck. Hope you can help me out. Quote Link to comment Share on other sites More sharing options...
discomatt Posted April 1, 2008 Share Posted April 1, 2008 ../ would be the correct syntax. Please post your entire directory tree. You are referencing a file that is hidden to the user running PHP or a file that doesn't exist. Quote Link to comment Share on other sites More sharing options...
EchoFool Posted April 1, 2008 Author Share Posted April 1, 2008 Root(folder) - CSS(folder) - page.php - Connect(folder) - include.php Thats my directory tree. Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted April 1, 2008 Share Posted April 1, 2008 try include('./../../connect/include.php'); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.