Page 1 of 1

$_SERVER error

Posted: Sat May 01, 2004 10:07 pm
by Josh
I don't know why, but

Code: Select all

<?php 
echo "Your IP Address: ", $_SERVER['REMOTE_ADDR'];
?>


Always returns an error for me /cry.gif' class='bbc_emoticon' alt=':(' /> Why would this be? Anyone know?

~Josh

$_SERVER error

Posted: Sat May 01, 2004 10:16 pm
by RuffRyders
Josh can you tell us the error you get?

$_SERVER error

Posted: Sat May 01, 2004 11:28 pm
by Josh
[quote name='Stupid PHP Stuff!!!']Server Address:
Notice: Undefined index: SERVER_ADDR in serverip.php on line 2[/quote]

Line 2:

[quote name='AGAIN! The stupid PHP Stuff!!']echo "Server Address: ", $_SERVER['SERVER_ADDR'];[/quote]

and sorry, it wasn't 'REMOTE_ADDR', it was the above /blum.gif' class='bbc_emoticon' alt=':P' />

~Josh

$_SERVER error

Posted: Sat May 01, 2004 11:29 pm
by Josh
(punch) /Debate.gif' class='bbc_emoticon' alt='(debate)' /> Stupid thing >.<

~Josh

$_SERVER error

Posted: Sun May 02, 2004 4:49 am
by Scott
try

Code: Select all

<? echo "Server Address: " .$_SERVER['SERVER_ADDR']; ?>

$_SERVER error

Posted: Sun May 02, 2004 2:56 pm
by Sp3culuM

Code: Select all

<?
$ip = $_SERVER["REMOTE_ADDR"];
echo $ip;
?>
Works fine..

$_SERVER error

Posted: Mon May 03, 2004 1:58 am
by Freak
btw its better to use getenv("REMOTE_ADDR");

$_SERVER error

Posted: Sat May 15, 2004 6:43 am
by Jim
The reason you have to put $_SERVER['SERVER_ADDR'] is because global variables are turned off. If you have php installed on your computer this is an easy fix, if not then you will have to live with $_SERVER['SERVER_ADDR'] in stead of $SERVER_ADDR.
If php is on your local computer open the php.ini file c:\windows\php.ini and go to about line 365 or search for register_globals.

If the line reads:
register_globals = Off, change it to register_globals = On
If the line reads:
register_globals = On, then you have a problem with php. Try restarting you computer. Hope this helps.