Newbie - PHP Include error

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have this php file called links.php.  It is in a folder on my domain  

The file links.php has an include statement:


When I run links.php, I get the below listed at the bottom of this message.

If however, I place links.php in the same folder as k.php and use the  
include statement include('k.php'); it works without any errors.

Would someone know what would be the correct syntax for the include  
statement so that I can place links.php in the links folder rather then  

Thank you

Error message
Warning: main(\folderc\test.php): failed to open stream: No such file or  
directory in /usr/www/virtual/userid/ on line  

Warning: main(): Failed opening '\folderc\test.php' for inclusion  
(include_path='.:/usr/local/lib/php') in  
/usr/www/virtual/userid/ on line 6

Re: Newbie - PHP Include error

Quoted text here. Click to load it

1. do you have a file called k.php living in /folderc/ off ROOT - probably  
not.  Where is folderc?
2. use forward slashes for directories to maintain cross-server  

Re: Newbie - PHP Include error

Quoted text here. Click to load it

If folderc is a subdirectory of folder links try this:


If folderc is on the same level as folder links then try this:



Re: Newbie - PHP Include error

Amy wrote:
Quoted text here. Click to load it

I suspect you're expecting the root directory for your include to be the  
same as the root directory for your web server.  It's not - PHP goes  
straight to the file system, not your web server.  So the root directory  
is that of your file system and not the web server.

To refer from the web server's document root (no matter where you are), use
   include ($_SERVER['DOCUMENT_ROOT'] . '/folderc/test.php';

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Site Timeline