Page 1 of 1
terrible path error
Posted: Sun Jun 26, 2005 6:17 am
by Ree
hi all, i'm having a hard time trying to fix the path error i recieve. i'll explain the file organization a bit.
the files of the site are all put in '/htdocs/stuff'. so, in that same directory i have a cfg.php file which contains:
Code: Select all
<?php
define('root', '/htdocs/stuff');
?>
i have a file switch_page_admin.php which is in '/htdocs/stuff/func' and i need to include it in index.php which is in '/htdocs/stuff/admin'. what i do is inlude cfg.php, and use the constant 'root' to indicate the path of switch_page_admin.php. here's how it looks in index.php:
Code: Select all
<?php
include('../cfg.php'); //since index.php is in '/htdocs/stuff/admin' and cfg.php is in '/htdocs/stuff'
include(root . '/func/switch_page_admin.php');
?>
i get (Warning: main(/htdocs/stuff/func/switch_page_admin.php): failed to open stream: No such file or directory) when i run index.php although i double checked - switch_page_admin.php is there (in '/htdocs/stuff/func'). now what do i do wrong here? i'm a true beginner so i probably missed something.
Posted: Sun Jun 26, 2005 7:53 am
by Chris Corbyn
Are you sure /htdocs is in the root of the filesystem and
not just the root of your home directory? is this a shared server?
This should tell you...
Wherever you put that PHP script will show you the full filesystem path to it

Posted: Sun Jun 26, 2005 8:06 am
by Ree
yes, i'm sure '/htdocs' is the root dir. btw it's a local server on my pc.
the thingy you told me, it just showed me i have the dirs all indicated correct. now really, i don't get what's wrong...
Posted: Sun Jun 26, 2005 8:36 am
by wwwapu
If I undestood right your folderstructure is something like this:
Code: Select all
їhtdocs]
їstuff]
їadmin]
index.php
ї/admin]
їfunc]
switch_page_admin.php
ї/func]
cfg.php
ї/stuff]
ї/htdocs]
And if it is, it works. Tested this myself. Are you absolutely sure, that all filenames are lowercase and spelled just as they are written here.
Posted: Sun Jun 26, 2005 8:59 am
by Ree
wwwapu, that's exactly how the files are stored. i double checked upper and lowercase things, and it's all correct, all are lowercase, both in scripts and file system. you say it runs on your side well? what i find extremely weird is that the error says Warning: main(/htdocs/stuff/func/switch_page_admin.php): failed to open stream: No such file or directory in E:\Software\Server\Apache2\htdocs\stuff\admin\index.php on line 10 when /htdocs/stuff/func/switch_page_admin.php DOES exist.
maybe there's a php setting i should change? but i somehow doubt it since the settings are pretty much default. if you have any suggestions please let me know.
Posted: Sun Jun 26, 2005 10:42 am
by timvw
you forgot a $ for root... so include($root . 'whatever');
you migh also want to have a look at the "include_path" setting.
Posted: Sun Jun 26, 2005 10:54 am
by Revan
timvw wrote:you forgot a $ for root... so include($root . 'whatever');
you migh also want to have a look at the "include_path" setting.
No, it's a constant..
Posted: Sun Jun 26, 2005 12:09 pm
by Ree
i have just checked the same on another pc, the same result. should i change include_path as suggested? and how? mine is commented in php.ini.