Page 1 of 1

$_SERVER error

Posted: Sun May 02, 2004 5:07 am
by Josh
I don\'t know why, but

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

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

~Josh

$_SERVER error

Posted: Sun May 02, 2004 5:16 am
by RuffRyders
Josh can you tell us the error you get?

$_SERVER error

Posted: Sun May 02, 2004 6:28 am
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: Sun May 02, 2004 6:29 am
by Josh
(punch) /Debate.gif\' class=\'bbc_emoticon\' alt=\'(debate)\' /> Stupid thing >.<

~Josh

$_SERVER error

Posted: Sun May 02, 2004 11:49 am
by Scott
try [code]<? echo "Server Address: " .$_SERVER[\'SERVER_ADDR\']; ?>[/code]

$_SERVER error

Posted: Sun May 02, 2004 9:56 pm
by Sp3culuM
[code]<?
$ip = $_SERVER["REMOTE_ADDR"];
echo $ip;
?>[/code]

Works fine..

$_SERVER error

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

$_SERVER error

Posted: Sat May 15, 2004 1:43 pm
by Jim
The reason you have to put [color=\"purple\"]$_SERVER[\'SERVER_ADDR\'][/color] 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 [color=\"purple\"]$_SERVER[\'SERVER_ADDR\'][/color] in stead of [color=\"purple\"]$SERVER_ADDR[/color].
If php is on your local computer open the [color=\"red\"]php.ini[/color] file [color=\"blue\"]c:\windows\php.ini[/color] and go to about line [color=\"red\"]365[/color] or search for [color=\"blue\"]register_globals[/color].

If the line reads:
[color=\"red\"]register_globals = Off[/color], change it to [color=\"red\"]register_globals = On[/color]
If the line reads:
[color=\"blue\"]register_globals = On[/color], then you have a problem with php. Try restarting you computer. Hope this helps.