Dynadot โ€” .com Registration $8.99

GEO-IP with PHP

Spaceship Spaceship
Watch

darmar

Established Member
Impact
0
Hi


I need a little help.

I'm using
http://api.hostip.info/country.php
to fetch the locale of the visitor.

I'd like to fetch this through my PHP script, with something like this:
$locale = @file("http://api.hostip.info/country.php");

But, then this web service doesn't fetch my visitors location, but my web server location.

I need tihs to programatically set the default language for my multilanguage website.

Does anybody have any idea how to "fix" this ?


Thank you
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
just had a quick look on their site and it just seems a simple case of you not putting the ip variable on the address you should have:-

PHP:
ip = $_SERVER['REMOTE_ADDR'];
$locale = @file("http://api.hostip.info/country.php?ip=".$ip);
 
0
•••
You should look for another solution, because this one will always show the GEOinfo of the host calling the script (i.e.: your own IP).

I have a geoinfo script running here:

http://fadlan.com/ip

and this one lets you enter the desired IP:

http://fadlan.com/ip2c


Regards.
 
0
•••
guillermobt said:
You should look for another solution, because this one will always show the GEOinfo of the host calling the script (i.e.: your own IP).

I have a geoinfo script running here:

http://fadlan.com/ip

and this one lets you enter the desired IP:

http://fadlan.com/ip2c


Regards.

Ther service he is using allows you to specify the IP it is just a case for some reason he has not.
 
0
•••
I messed around with it for a bit and created http://mf1.us/ip - Their database isn't really big enough yet though.
 
0
•••
Yup, that's it, I forgot about it.... I'm screeming to myself now - RTFM !!!! :)

Thanks !
 
0
•••
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back