Page 1 of 1

$_SERVER[Remote_Addr] means???

Posted: Wed May 10, 2006 11:43 pm
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

Posted: Wed May 10, 2006 11:46 pm
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

Posted: Thu May 11, 2006 5:48 am
by dibyendrah
Try

Code: Select all

$HTTP_SERVER_VARS['REMOTE_ADDR']
rather than

Code: Select all

$_SERVER['REMOTE_ADDR'] 
.

Posted: Thu May 11, 2006 6:25 am
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 :)

Posted: Thu May 11, 2006 1:38 pm
by timvw
If you run a script via the commandline, $_SERVER['REMOTE_ADDR'] doesn't exist..

Posted: Thu May 11, 2006 4:09 pm
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!