$_SERVER error

Support, Snippets & Projects

Moderators: Moderator, Global Moderator

Post Reply
Josh
Hero Member
Hero Member
Posts: 4627
Joined: Fri Jun 04, 2004 7:54 am

$_SERVER error

Post 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
[align=center]

Image

“If you stop learning, you stop living.” ~Tami Quiring

“It's the rare man who understands the value of a single perfect rose.”

[/align]
RuffRyders
Hero Member
Hero Member
Posts: 1138
Joined: Mon Jun 14, 2004 12:47 am

$_SERVER error

Post by RuffRyders »

Josh can you tell us the error you get?
The bruises fade but memories are made.
Josh
Hero Member
Hero Member
Posts: 4627
Joined: Fri Jun 04, 2004 7:54 am

$_SERVER error

Post 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
[align=center]

Image

“If you stop learning, you stop living.” ~Tami Quiring

“It's the rare man who understands the value of a single perfect rose.”

[/align]
Josh
Hero Member
Hero Member
Posts: 4627
Joined: Fri Jun 04, 2004 7:54 am

$_SERVER error

Post by Josh »

(punch) /Debate.gif' class='bbc_emoticon' alt='(debate)' /> Stupid thing >.<

~Josh
[align=center]

Image

“If you stop learning, you stop living.” ~Tami Quiring

“It's the rare man who understands the value of a single perfect rose.”

[/align]
Scott
Administrator
Administrator
Posts: 1651
Joined: Sun Apr 25, 2004 6:08 am

$_SERVER error

Post by Scott »

try

Code: Select all

<? echo "Server Address: " .$_SERVER['SERVER_ADDR']; ?>
Sp3culuM
Hero Member
Hero Member
Posts: 662
Joined: Mon May 17, 2004 7:36 am

$_SERVER error

Post by Sp3culuM »

Code: Select all

<?
$ip = $_SERVER["REMOTE_ADDR"];
echo $ip;
?>
Works fine..
Image
Freak
Newbie
Newbie
Posts: 3
Joined: Wed Jun 16, 2004 5:37 pm

$_SERVER error

Post by Freak »

btw its better to use getenv("REMOTE_ADDR");
Jim
Administrator
Administrator
Posts: 1324
Joined: Wed Jun 16, 2004 5:37 pm

$_SERVER error

Post 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.
Love is all a matter of timing.

It's no good meeting the right person too soon or too late.

If I'd live in another time or place...

...my story might have had a very different ending.
Post Reply

Return to “PHP &amp; MySQL”