problem with predefined variables

problem with predefined variables

am 05.04.2005 17:09:55 von SG Edwards

Hi,

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


echo "you are running the file $PHP_SELF.

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


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 .


you are viewing this page usinig:
PHP Notice: Undefined variabl=
e:=20
HTTP_USER_AGENT in /home/s0460205/public_html/test.php on line 11

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

Re: problem with predefined variables

am 05.04.2005 17:25:21 von Christopher Kings-Lynne

> 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 .


> you are viewing this page usinig:
PHP Notice: Undefined variable:
> HTTP_USER_AGENT in /home/s0460205/public_html/test.php on line 11
>

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