Can't include using $_SERVER['DOCUMENT_ROOT']

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shadow_005
Forum Newbie
Posts: 8
Joined: Sat Oct 08, 2005 1:12 pm

Can't include using $_SERVER['DOCUMENT_ROOT']

Post by shadow_005 »

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


I have a dir in the root dir called "Includes".
But for some reason i can't access it unless i hard code it (I have full admin rights). The last thing i want to do is hard coding something.

If i use this code in the main page it works:

Code: Select all

include("Includes/Config.inc");
If i use this code in the main page it doesnt work:

Code: Select all

include($_SERVER['DOCUMENT_ROOT']."/Includes/Config.inc");
It produces this error:
failed to open stream: No such file or directory
Why?


Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

emit the variable, maybe you are working with it wrong.. or it may be set wrong or not at all..
shadow_005
Forum Newbie
Posts: 8
Joined: Sat Oct 08, 2005 1:12 pm

Post by shadow_005 »

Haha, i emitted it all the time. It was
c:/program files/easyphp1-8/www
But ofcourse i forgot that the actual project is in another directory... Problem solved thanks.
(I just noticed it when i hit the preview button in this post)


And sorry about the php tags. :oops:
Post Reply