Page 1 of 1

relative path (../path/to/file.php) does not work!

Posted: Thu Apr 09, 2009 11:36 pm
by anjan011
Hi I am suddenly in this situation ..

i have a file structure like this --

incs
-----config.inc.php
-----db.inc.php
----------------
classes
-----cars.php
-----wheels.php
----------------

in cars.php i includes the config.inc.php by this ..

require_once('../incs/config.inc.php');

it gives me a fatal error -

Fatal error: require_once() [function.require]: Failed opening required
'../incs/config.inc.php' (include_path='.;C:\php5\pear') in
C:\wamp\www\NewFolder\classes\cars.php on line 5

but if i use this -

require_once('./incs/config.inc.php');

the script works perfectly ..

other scripts are running well with the ../incs/files.php but this script isn't

any help?

regards,
Anjan

Re: relative path (../path/to/file.php) does not work!

Posted: Fri Apr 10, 2009 2:34 am
by corkman
your include_path contains ".", so require should seek in the current directory.

So, if this works:
require_once('./incs/config.inc.php');
then the directory incs must be the the subdirectory of classes, where you run the script cars.php.

Are you sure, that the tree you drawn is correct?