Reply to Re: include("/main.php") won't work on a hosting machine

Your name:

Reply:


Posted by Chuck Anderson on 06/19/07 20:03

Jerry Stuckle wrote:
> Summercoolness@gmail.com wrote:
>
>> if you are just a users among the 100s of users on a hosting machines,
>> then if you do a include("/main.php"); it won't include the file
>> but will say
>>
>> Failed opening required '/main.php' (include_path='.:/usr/local/nf/
>> lib/php')
>>
>> it seems ok to include("../main.php"); except the file will not work
>> if moved from www.abc.com/movies to a new location of
>> www.abc.com/movies/little-mermaid is there a better solution for
>> this?
>>
>>
>
> include ($_SERVER['DOCUMENT_ROOT']) . '/main.php');
>
> That way you don't have to worry about include paths, which some hosts
> don't allow you to change. It also works on IIS, which doesn't have
> .htaccess.
>
>

Wow. Serendipity? Synchronicity? ... I was about to ask this very same
question ... downloaded today's new messages, and I see someone did it
for me (thanks to summercoolness).

And it is also came to me just this morning that ....

include "{$_SERVER['DOCUMENT_ROOT']}/file_to_include.php";

.... was the solution.

But .... do you happen to understand why "/" does not work with include
to indicate the root dir?

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
*****************************

[Back to original 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

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