You are here: Re: Newbie - PHP Include error « PHP Programming Language « IT news, forums, messages
Re: Newbie - PHP Include error

Posted by Jerry Stuckle on 06/22/07 12:21

Amy wrote:
> I have this php file called links.php. It is in a folder on my domain
> (www.domain.com/links/links.php)
>
> The file links.php has an include statement:
>
> <?php
> include('\folderc\k.php');
>
> 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
> folderc.
>
> Thank you
>
> Error message
> Warning: main(\folderc\test.php): failed to open stream: No such file or
> directory in /usr/www/virtual/userid/www.domain.com/links/links.php on line
> 6
>
> Warning: main(): Failed opening '\folderc\test.php' for inclusion
> (include_path='.:/usr/local/lib/php') in
> /usr/www/virtual/userid/www.domain.info/links/links.php on line 6
>
>
>

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.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация