PDA

View Full Version : Newbie PHP question



Red_Avatar
05-01-2007, 03:44 PM
I'm having a bit of a problem - I'm trying to use PHP but for some reason, I can't get it to work. I made a simple file called "index.php" on my webserver with the content:

<?php print "My ip is: $REMOTE_ADDR"; ?>

Just to see if php would work and it won't return the IP. The site where I got the code from does show the IP. Is there anything I need to do to get it working?

Chella
05-01-2007, 07:32 PM
Try using this and seeing if it works:


<?php
//Gets the IP address
$ip = getenv("REMOTE_ADDR") ;
Echo "Your IP is " . $ip;
?>

esabogal
05-01-2007, 07:36 PM
This is because you must have registered globals on.

Normally found on the php.ini file.

register_globals = On

Seb
05-02-2007, 12:12 AM
This works

echo 'My IP is ' . $_SERVER['REMOTE_ADDR'];