1

I'm using maxmind GeoLiteCity to show city name base on user IP address, it show for some of cities but not for all cities. Here's my code: I downloaded latest GeoLiteCity.dat from following link: http://dev.maxmind.com/geoip/legacy/geolite/

include("geoipcity.inc");
include("geoipregionvars.php");
$ip = $_SERVER['REMOTE_ADDR']; 
$gi = geoip_open("GeoLiteCity.dat",GEOIP_STANDARD);
$record= geoip_record_by_addr($gi,$ip);
echo 'City Name: '.$record->city . "\n";
geoip_close($gi);

how to solve it ?

Thanks

Alex Mocha
  • 19
  • 3
  • All other IP to location concerns aside (proxies etc) even on MaxMind's own site they state that that data is only 67% accurate ... what exactly are you expecting? – CD001 Oct 13 '15 at 14:28
  • I know, but it doesn't work even for main capital cities, like Netherlands, Amsterdam not showing, like, Germany, Berlin not showing, but a few countries it shows. – Alex Mocha Oct 13 '15 at 14:32
  • OK - that does sound well off the mark, their data isn't that bad (demo of their latest version as a web service : https://www.maxmind.com/en/geoip-demo) ... and whilst `$_SERVER['REMOTE_ADDR']` isn't 100% guaranteed to retrieve the actual user's IP address it shouldn't be massively far off. – CD001 Oct 13 '15 at 14:38
  • Yes you are right even in demo I can't get city name, It mentioned Germany / Europe. so it means maxmind data isn't perfect, cause I can get exact location name, berlin in other services like iplocation.net anyway thanks for your time bro. thumbs up – Alex Mocha Oct 13 '15 at 14:50
  • Data does seem a little odd, Berlin *is* in there (downloaded the CSV and had a look) but it may not map up very well... whilst other data seems to be very specific. I just used their demo tool to check the IP addresses for welt.de and visitberlin.de (195.50.176.200, 5.9.135.159). The welt.de lookup was quite specific whilst visitberlin was just *Germany, Europe* ... odd – CD001 Oct 13 '15 at 14:57
  • This is exactly what I'm telling, data isn't perfect. exactly like 5.9.135.159. – Alex Mocha Oct 13 '15 at 15:04
  • visitberlin.de (5.9.135.159) is a web site. So it should report the data center location instead of Berlin. I believe the site is hosted in Hetzner in Nuremberg based on http://www.ip2location.com/5.9.135.159. – Michael C. Oct 13 '15 at 18:39

0 Answers0