problem with predefined variables

Hi,

I am just learning PHP and have a very simple script to access data in a
predefined variable as follows:

<body>
<?php
echo "you are running the file <b>$PHP_SELF</b>.

\n";
echo 'you are viewing this page usinig:
<b>', $HTTP_USER_AGENT, '</=
b><br
/>from the IP address ', $REMOTE_ADDR;
?>
</body>

However, the assignment does not happen, giving the command line error (P=
HP
Notice: Undefined variable: PHP_SELF in /home/s0460205/public_html/test=
..php
on line 10
you are running the file <b></b>.


you are viewing this page usinig:
<b>PHP Notice: Undefined variabl=
e:
HTTP_USER_AGENT in /home/s0460205/public_html/test.php on line 11
</b>
from the IP address PHP Notice: Undefined variable: REMOTE_AD=
DR in
/home/s0460205/public_html/test.php on line 11)

- why would this occur?

Many thanks

(I am running PHP/4.3.10)


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
SG Edwards [ Di, 05 April 2005 17:09 ] [ ID #730227 ]

Re: problem with predefined variables

> However, the assignment does not happen, giving the command line error (PHP
> Notice: Undefined variable: PHP_SELF in /home/s0460205/public_html/test.php
> on line 10
> you are running the file <b></b>.


> you are viewing this page usinig:
<b>PHP Notice: Undefined variable:
> HTTP_USER_AGENT in /home/s0460205/public_html/test.php on line 11
> </b>
from the IP address PHP Notice: Undefined variable: REMOTE_ADDR in
> /home/s0460205/public_html/test.php on line 11)
>
> - why would this occur?

You have register_globals = off in your php.ini.

Try $_SERVER['PHP_SELF'] and $_SERVER['HTTP_USER_AGENT'] and
$_SERVER['REMOTE_ADDR']

And read about superglobals and register_globals in the PHP docs.

Chris

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org
Christopher Kings-Lyn [ Di, 05 April 2005 17:25 ] [ ID #730228 ]
Datenbanken » gmane.comp.db.postgresql.php » problem with predefined variables

Vorheriges Thema: Retrieve a list of databases using PHP
Nächstes Thema: sql command