Board index   FAQ   Search  
Register  Login
Board index PHP PHP Installation

Undefined variable: DOCUMENT_ROOT

Forum for you who has PHP installation issues

Moderators: macek, egami, gesf

Undefined variable: DOCUMENT_ROOT

Postby sam » Sat Jun 22, 2002 6:48 am

Hi there everybody

I'm having a little trouble with the HTTP variables. I have just installed Apache 1.3.24 and the latest version of PHP. I installed it as a sapi module and everything went fine. However when trying to make references to the reserved HTTP variables like:

HTTP_REFERER
DOCUMENT_ROOT


I get errors, this is what is outputted

Notice: Undefined variable: HTTP_REFERER in d:\home\httpd\html\pcm_staff\index.php on line 3

Notice: Undefined variable: DOCUMENT_ROOT in d:\home\httpd\html\pcm_staff\index.php on line 10

Its a little odd because when I check phpinfo(); the HTTP_REFERER and DOCUMENT_ROOT appear with the correct values.

Has anybody got any ideas. Thanks
sam
New php-forum User
New php-forum User
 
Posts: 4
Joined: Sat Jun 22, 2002 6:43 am
Location: South Africa

Re: Undefined variable: DOCUMENT_ROOT

Postby WiZARD » Sat Jun 22, 2002 11:38 pm

Hi!
I'm to have this problem. :!:
But if you carefully see at the httpd.conf in Apache, you can see next:
#AddModule mod_headers.c :!:
All this variables not permit Apache.
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby sam » Sun Jun 23, 2002 1:12 am

Thanks, I worked out what the problem is, try use:

$HTTP_SERVER_VARS['DOCUMENT_ROOT']

in the new versions of php > 4.1 the setting of "register_globals" is set to "off" by default. You can change it if you search your php.ini for the line where register_globals is defined and set it to "on".

Cheers
sam
New php-forum User
New php-forum User
 
Posts: 4
Joined: Sat Jun 22, 2002 6:43 am
Location: South Africa

Postby Faithless » Sun Jun 23, 2002 6:54 pm

or $_SERVER['DOCUMENT_ROOT']

This also affects accessing posta nd cookies variables.
Faithless
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sun Jun 09, 2002 12:32 pm

Postby WiZARD » Sun Jun 23, 2002 10:49 pm

I do not know how you config yours Apache and PHP, but at my comp all work

OS Windows 98SE

Apache: 1.3.24
PHP: 4.2.1

Than I type next in test.php:
Code: Select all
<?PHP
echo ($HTTP_SERVER_VARS['DOCUMENT_ROOT'])
?>

I see in my local server http://student/test.php:
c:/apache/apache/htdocs
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby khote » Tue Jul 23, 2002 6:17 am

This is from my httpd.conf. I have commented out the default location they chose and changed it to a more genearl /var/www/html
Make this change yourself (to wherever you want your web root), stop and start apache.
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
#DocumentRoot "/usr/local/apache/htdocs"
DocumentRoot "/var/www/html"

getenv("DOCUMENT_ROOT") also works for me, without having to worry about register_globals ...
khote
New php-forum User
New php-forum User
 
Posts: 7
Joined: Tue Jul 23, 2002 6:15 am
Location: San Bernardino, Ca, USA


Return to PHP Installation

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron