chrici Posted May 24, 2011 Share Posted May 24, 2011 Hi all.In the top of my document (above <html>) I have set the variable $fullPath to the following: $fullPath = 'http://'.$_SERVER['HTTP_HOST'].'/'; So the document is placed in: $fullPath . "myfolder/mydocument.php".What I want to do is to access the include files placed in: $fullPath . "includes/whatever-to-include.php". require_once($fullPath.'includes/whatever-to-include.php'); But when I try to include (require) the files something goes wrong and it breaks the code.I am using WAMP Server to develop my site. I have an idea that WAMP might be the problem (?).Hope you can help me Link to comment Share on other sites More sharing options...
jeffman Posted May 24, 2011 Share Posted May 24, 2011 Why not use a relative path?Have you echoed $_SERVER['HTTP_HOST'] to see what kind of path you are generating? It might not be what you think. Link to comment Share on other sites More sharing options...
chrici Posted May 24, 2011 Author Share Posted May 24, 2011 It outputs http://localhost/ when I echo $fullPath - as expected.So by using a relative path I should type the following? require_once('../includes/whatever-to-include.php'); Link to comment Share on other sites More sharing options...
jeffman Posted May 24, 2011 Share Posted May 24, 2011 It would depend on where the calling file is. Link to comment Share on other sites More sharing options...
chrici Posted May 24, 2011 Author Share Posted May 24, 2011 The calling file is placed in http://localhost/myfolder/myfile.php.And I need to access http://localhost/includes/whatever-to-include.php.Using require_once('../includes/whatever-to-include.php'); doesn't seem to work. Link to comment Share on other sites More sharing options...
ShadowMage Posted May 24, 2011 Share Posted May 24, 2011 Are you getting any error messages? Link to comment Share on other sites More sharing options...
chrici Posted May 24, 2011 Author Share Posted May 24, 2011 No - just a blank page.Is there a method to display errors? Link to comment Share on other sites More sharing options...
chrici Posted May 24, 2011 Author Share Posted May 24, 2011 Just found the the problem :)In the included file I am including another file. It is the path to the second included file that was problem.Thanks for your help! Link to comment Share on other sites More sharing options...
Synook Posted May 25, 2011 Share Posted May 25, 2011 To show errors, change the value of error_reporting in php.ini. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.