Page 1 of 1

require_once problems

Posted: Tue Sep 11, 2007 6:19 pm
by davisaggie
in my code I have:

Code: Select all

require_once("file_array.php");
file_array.php exists in my root web directory, but the script I am running is in a directory that resides in the web directory. If I run the script as is, I get the following messages:

Code: Select all

Warning: require_once(file_array.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\test\report_view.php on line 5

Fatal error: require_once() [function.require]: Failed opening required 'file_array.php' (include_path='.;C:\xampp\php\pear\; C:\xampp\htdocs\') in C:\xampp\htdocs\test\report_view.php on line 5
C:\xampp\htdocs is my root web directory and I have checked, and file_array.php does exist in that directory. The script only works if I use:

Code: Select all

require_once("C:\\xampp\\htdocs\\file_array.php");
OR

Code: Select all

require_once("../file_array.php");
I thought that by having the directory C:\xampp\htdocs in the include_path in my php.ini I didn't need to fully qualify the file location. Did I miss something in the php doc?

Posted: Tue Sep 11, 2007 6:29 pm
by feyd
Maybe it's the space you have before the path. :?:

Posted: Tue Sep 11, 2007 6:33 pm
by davisaggie
feyd wrote:Maybe it's the space you have before the path. :?:
D'OH!!!! Yup that was it :oops:. Thanks feyd.