Page 1 of 1

[SOLVED]include_once for files @root

Posted: Sun Aug 29, 2004 3:49 am
by vigge89
How can I include_once a file which is located in the server root (/) ?
I've tried include_once('/global.php'); but I get the following error:
Warning: main(/global.php) [function.main]: failed to open stream: No such file or directory in J:\Server\htdocs\index.php on line 6

Fatal error: main() [function.require]: Failed opening required '/global.php' (include_path='.;J:\Server\xampp\php\pear'') in J:\Server\htdocs\index.php on line 6
What's wrong?
Thanks in advance.

Posted: Sun Aug 29, 2004 7:23 am
by wwwapu
You should go up-path by ../global.php or something like that

Posted: Sun Aug 29, 2004 7:28 am
by vigge89
wwwapu wrote:You should go up-path by ../global.php or something like that
it isn't possible to load it from the root?
the problem is that im using mod_rewrite for nicer urls, which makes the number of folders from the root be uknown :(

Posted: Sun Aug 29, 2004 8:01 am
by timvw
As you are already using .htaccess to rewrite, you could also add a

php_value "include_path" ".;/path/to/root" line ;)

Btw, in windows you need to separate them with ; in unix with :

Posted: Sun Aug 29, 2004 11:34 am
by vigge89
problem is that the local (my computers) and remote (vigge.net) server is on different platforms, mine's on win32, while vigge.net is on linux.

Posted: Sun Aug 29, 2004 11:48 am
by m3mn0n
*drive by posting*

Develop on Linux! It's better! :)

Posted: Sun Aug 29, 2004 11:50 am
by vigge89
Sami wrote:*drive by posting*

Develop on Linux! It's better! :)
probably, but I only have 1 computer, and I want to be able to play games and stuff on it too :P

Posted: Sun Aug 29, 2004 12:02 pm
by timvw
Well, on localhost i edit the php.ini....... and at the remote server i use a .htaccess :)

Posted: Sun Aug 29, 2004 12:03 pm
by vigge89
alright, thanks :)

Posted: Sun Aug 29, 2004 2:30 pm
by andre_c
Or you could try this:

Code: Select all

<? include_once $_SERVER['DOCUMENT_ROOT'] . '/global.php'; ?>