$_SERVER[Remote_Addr] means???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jvandal
Forum Newbie
Posts: 1
Joined: Wed May 10, 2006 11:34 pm

$_SERVER[Remote_Addr] means???

Post by jvandal »

This is a statement from a php counter .
----------------------------------------------------

Code: Select all

$check_sql = sprintf("SELECT time + 0 FROM %s WHERE visit_date = CURDATE() AND ip_adr = '%s' ORDER BY time DESC LIMIT 0, 1", $this->table_name, $_SERVER['REMOTE_ADDR']);
-------------------------------------------------------------
This is the error message and I don't know what it means

Code: Select all

================================================
<b>Notice</b>:  Undefined index:  REMOTE_ADDR in <b>C:\mysites\sitey\counter\count_visitors_class.php</b> on line <b>51</b><br />
==================================================
Any help will be appreciated
JIm
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

that is the reserved variable for the ip address of the user.

I'm not sure why it's giving you an error.

here is a list of the $_SERVER variables array.

http://www.php.net/reserved.variables

btw...use php tags when posting code in the forum...I have fixed your post this time, but for future reference, it makes it easier on all of us :D
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

Try

Code: Select all

$HTTP_SERVER_VARS['REMOTE_ADDR']
rather than

Code: Select all

$_SERVER['REMOTE_ADDR'] 
.
AshrakTheWhite
Forum Commoner
Posts: 69
Joined: Thu Feb 02, 2006 6:47 am

Post by AshrakTheWhite »

its just a notice all you need to do is:

Code: Select all

$_SERVER['REMOTE_ADDR'] = array();
before you start using it

you can supress it by

Code: Select all

error_reporting(E_ERROR | E_WARNING | E_PARSE);
Reporting E_NOTICE can be good too (to report uninitialized variables or catch variable name misspellings ...)


but its usually a pain :)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

If you run a script via the commandline, $_SERVER['REMOTE_ADDR'] doesn't exist..
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

timvw wrote:If you run a script via the commandline, $_SERVER['REMOTE_ADDR'] doesn't exist..
ya learn something new every day...thx tim!
Post Reply