DataSpy Posted January 20, 2008 Share Posted January 20, 2008 I know including a file isn't very hard but for some reason it's not working. include ("../admin/config.php"); I KNOW that's where the file is but I get the error Warning: include(../admin/config.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\www\trade\includes\search.php on line 3 and Warning: include() [function.include]: Failed opening '../admin/config.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\www\trade\includes\search.php on line 3 The same file includes in other pages just fine but I don't go more than one folder deep and I was thinking that might be the problem. Example of another page I include the same file in include ("admin/config.php"); This works perfectly ??? Any help would be greatly appreciated, thanks in advance! Link to comment https://forums.phpfreaks.com/topic/86943-help-with-includeing-a-file/ Share on other sites More sharing options...
Vivid Lust Posted January 20, 2008 Share Posted January 20, 2008 try making a direct path with http://www.site/admin/config.php Link to comment https://forums.phpfreaks.com/topic/86943-help-with-includeing-a-file/#findComment-444492 Share on other sites More sharing options...
budimir Posted January 20, 2008 Share Posted January 20, 2008 I know including a file isn't very hard but for some reason it's not working. include ("../admin/config.php"); I KNOW that's where the file is but I get the error Warning: include(../admin/config.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\www\trade\includes\search.php on line 3 and Warning: include() [function.include]: Failed opening '../admin/config.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\www\trade\includes\search.php on line 3 The same file includes in other pages just fine but I don't go more than one folder deep and I was thinking that might be the problem. Example of another page I include the same file in include ("admin/config.php"); This works perfectly ??? Any help would be greatly appreciated, thanks in advance! Actually what could help you is: include(../admin/config.php); ---- loose the ../ and put include ("admin/config.php"); - this sould be fine When you are using ../ you are going one dir back. And if you are in current dir and want to access admin/config.php, then you do as above. Link to comment https://forums.phpfreaks.com/topic/86943-help-with-includeing-a-file/#findComment-444493 Share on other sites More sharing options...
DataSpy Posted January 20, 2008 Author Share Posted January 20, 2008 I know including a file isn't very hard but for some reason it's not working. include ("../admin/config.php"); I KNOW that's where the file is but I get the error Warning: include(../admin/config.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\www\trade\includes\search.php on line 3 and Warning: include() [function.include]: Failed opening '../admin/config.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\www\trade\includes\search.php on line 3 The same file includes in other pages just fine but I don't go more than one folder deep and I was thinking that might be the problem. Example of another page I include the same file in include ("admin/config.php"); This works perfectly ??? Any help would be greatly appreciated, thanks in advance! Actually what could help you is: include(../admin/config.php); ---- loose the ../ and put include ("admin/config.php"); - this sould be fine When you are using ../ you are going one dir back. And if you are in current dir and want to access admin/config.php, then you do as above. Thanks! I was trying to go up one folder that's why I added the ../ , I guess I didn't need to do that. Link to comment https://forums.phpfreaks.com/topic/86943-help-with-includeing-a-file/#findComment-444499 Share on other sites More sharing options...
chronister Posted January 20, 2008 Share Posted January 20, 2008 I struggled with this for a LONG TIME before I realized calling includes like this works no matter where your at in the file structure.. include($_SERVER['DOCUMENT_ROOT'].'/path/to/the/file.php'); This will start at the servers doc root and find the file that way. It works for me every time without problem. Hope this helps, Nate Link to comment https://forums.phpfreaks.com/topic/86943-help-with-includeing-a-file/#findComment-444520 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.