require_once problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
davisaggie
Forum Newbie
Posts: 16
Joined: Mon Aug 20, 2007 3:40 pm
Location: Salinas, CA

require_once problems

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Maybe it's the space you have before the path. :?:
davisaggie
Forum Newbie
Posts: 16
Joined: Mon Aug 20, 2007 3:40 pm
Location: Salinas, CA

Post by davisaggie »

feyd wrote:Maybe it's the space you have before the path. :?:
D'OH!!!! Yup that was it :oops:. Thanks feyd.
Post Reply