/    Sign up×
Community /Pin to ProfileBookmark

client IP Address

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

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@NogDogApr 22.2007 — $_SERVER['REMOTE_ADDR'] is correct.
Copy linkTweet thisAlerts:
@b_hunterApr 22.2007 — You're writing:
<i>
</i>
$clientip= $_SERVER['REMOTE_ADDR'];
echo $clientip;



?

If you are, it's possible that you are looking at your own visits/ip.
Copy linkTweet thisAlerts:
@ZnupiApr 22.2007 — It may be because you are behind one or more proxies.
Copy linkTweet thisAlerts:
@b_hunterApr 22.2007 — 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.
Copy linkTweet thisAlerts:
@ZnupiApr 22.2007 — 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.
Copy linkTweet thisAlerts:
@SolaarauthorApr 22.2007 — 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.
Copy linkTweet thisAlerts:
@NogDogApr 22.2007 — Use an alias for the count():
[code=php]
$query = "SELECT fldPostUID, COUNT(fldCommentUID) AS num_comment FROM msBlogComments GROUP BY fldPostUID ORDER BY num_comment";
[/code]
Copy linkTweet thisAlerts:
@SheldonApr 22.2007 — 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.
Copy linkTweet thisAlerts:
@SolaarauthorApr 23.2007 — 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.
Copy linkTweet thisAlerts:
@mrtbltDec 10.2007 — 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());
[/QUOTE]
×

Success!

Help @Solaar spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...