Click to See Complete Forum and Search --> : client IP Address
Solaar
04-22-2007, 03:26 AM
Hello,
I want to record visitors IP addresses when they visit my site, I was under the impression that $_SERVER['REMOTE_ADDR'] would do the trick but this returns the same IP regardless of who visits. Does anyone know why and have an alternative solution?
Solaar
NogDog
04-22-2007, 03:38 AM
$_SERVER['REMOTE_ADDR'] is correct.
b hunter
04-22-2007, 05:13 AM
You're writing:
$clientip= $_SERVER['REMOTE_ADDR'];
echo $clientip;
?
If you are, it's possible that you are looking at your own visits/ip.
Znupi
04-22-2007, 06:11 AM
It may be because you are behind one or more proxies.
b hunter
04-22-2007, 07:45 AM
How would the poster being behind a proxy stop the poster from viewing an ip address of someone else? I thought that if I proxy were to be used in this case, it would be the visitor using a proxy, thus, stopping the poster from seeing the visitor's ip address. Is that what you meant? I don't know much about proxies, though, so don't get offended. That's why I'm asking.
Znupi
04-22-2007, 08:39 AM
Me neither, but I know that proxies usually create problems with $_SERVER['REMOTE_ADDR']. I don't know if it is only the case of the user being behind the proxy, the server, or both, it was just a suggestion.
Solaar
04-22-2007, 08:39 AM
OK cheers guys, seems inconclusive will have to re-think. Can anyone help with this...
$query = "SELECT fldPostUID, COUNT(fldCommentUID) FROM msBlogComments GROUP BY fldPostUID";
I want to order the results by COUNT(fldCommentUID) but can't get the syntax right.
NogDog
04-22-2007, 02:14 PM
Use an alias for the count():
$query = "SELECT fldPostUID, COUNT(fldCommentUID) AS num_comment FROM msBlogComments GROUP BY fldPostUID ORDER BY num_comment";
Sheldon
04-22-2007, 02:59 PM
or on some servers (Mine) $_SERVER['REMOTE_ADDR'] returned my servers ip.
I had to use this
$_SERVER['HTTP_PC_REMOTE_ADDR'] And that worked fine.
Solaar
04-23-2007, 04:19 AM
Thanks NogDog, nice and easy. Sheldon that drew a blank i'm afraid - doesn't fetch anything. You're right about $_SERVER['REMOTE_ADDR'] returning my servers ip though. I fear I have a more deep-rooted problem. Thanks for the help.
mrtblt
12-10-2007, 05:10 AM
On the beginning of my index.php file, i inserted the following code to track the visitors who visit my website. But obviously, anytime when they return to the index page, the following code makes a recurring record. So how may i avoid this recurring recording each time when the visitor returns to the index page?
$clientip= $_SERVER['REMOTE_ADDR'];
$tarih = date('Y.m.d');
mysql_query("INSERT INTO visitors VALUES('$clientip','$tarih')") or die(mysql_error());