pdheady
asked on
$_SERVER['REMOTE_ADDR']; not working in PHP5
Here is the error I get from the code below.
PHP Notice: Undefined index: REMOTE_ADDR
This causing my entire script to fail.
Running PHP 5.1.6 (cli) (built: Apr 7 2009 08:00:04)
PHP Notice: Undefined index: REMOTE_ADDR
This causing my entire script to fail.
Running PHP 5.1.6 (cli) (built: Apr 7 2009 08:00:04)
<?
$ip=$_SERVER['REMOTE_ADDR'];
echo $ip;
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok I found problem and it's really my fault.
I'm running a web-service and connecting with client to web-service from the same server, so my IP detection was working just that the script was failing on output because of other syntax errrors. When debug on command line it was complaining about PHP Notice: Undefined index: REMOTE_ADDR
It is detecting the IP, but this still leads me to ask why is PHP still outputting that error on command line?
PHP Notice: Undefined index: REMOTE_ADDR
I'm running a web-service and connecting with client to web-service from the same server, so my IP detection was working just that the script was failing on output because of other syntax errrors. When debug on command line it was complaining about PHP Notice: Undefined index: REMOTE_ADDR
It is detecting the IP, but this still leads me to ask why is PHP still outputting that error on command line?
PHP Notice: Undefined index: REMOTE_ADDR
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thx
ASKER
Yes, REMOTE_ADDR is showing up in phpinfo(); test page and I see my IP address there.
I checked /etc/php.ini and register globals is off which should be fine.