Click to See Complete Forum and Search --> : $_SERVER['DOCUMENT_ROOT'] var not working


chrisg101
05-22-2003, 03:14 AM
I have the following line in my code:
$strIncludePrefix - $DOCUMENT_ROOT."inc/";

I keep getting the error:
'Notice: Undefined variable: DOCUMENT_ROOT in F:\php_www\includes\global.inc.php on line 21' when I run it.

I have also tried using $_SERVER['DOCUMENT_ROOT'] and I get the same thing. I am using PHP 4.3.1. Is there any reason why $DOCUMENT_ROOT would not work?

Please note I have auto globals turned on.

Any helps appreciated.
Thanks, Chris,

piersk
05-22-2003, 04:28 AM
The reason why $DOCUMENT_ROOT isn't working is because PHP thinks that it is a normal (i.e. not one set by the server/client) variable, and it is probably a way of telling you that nothing has been set for it yet.

I'm not sure as to why $_SERVER(DOCUMENT_ROOT] isn't working. though. However, I don't think that's what you need for your script, since you are asking for the directory name to be called a .inc file, i.e. you are telling it to look for a file called whatever you have stated the document root to be in the php.ini file. e.g. if your php.ini file stated that your document root was c:\, then your script would be looking for a file called c:\.inc (I think).

Sorry if this is a bit waffley.