$_SERVER error

Support, Snippets & Projects

Moderators: Moderator, Global Moderator

Post Reply
Josh
Hero Member
Hero Member
Posts: 4627
Joined: Fri Jun 04, 2004 2:54 pm

$_SERVER error

Post 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
[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 7: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 2:54 pm

$_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 2:54 pm

$_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 1:08 pm

$_SERVER error

Post by Scott »

try [code]<? echo "Server Address: " .$_SERVER[\'SERVER_ADDR\']; ?>[/code]
Sp3culuM
Hero Member
Hero Member
Posts: 662
Joined: Mon May 17, 2004 2:36 pm

$_SERVER error

Post by Sp3culuM »

[code]<?
$ip = $_SERVER["REMOTE_ADDR"];
echo $ip;
?>[/code]

Works fine..
Image
Freak
Newbie
Newbie
Posts: 3
Joined: Thu Jun 17, 2004 12:37 am

$_SERVER error

Post by Freak »

btw its better to use getenv("REMOTE_ADDR");
Jim
Administrator
Administrator
Posts: 1324
Joined: Thu Jun 17, 2004 12:37 am

$_SERVER error

Post 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.
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”