Question

I'm using MaxMind GeoIP with this script :

$gi = geoip_open(RESSOURCE_PATH.'/MaxMind/tests/data/GeoIPCity.dat', GEOIP_STANDARD);

// $rsGeoData = GeoIP_record_by_addr($gi, $_SERVER['REMOTE_ADDR']);
$rsGeoData = GeoIP_record_by_addr($gi, '91.213.180.118');

echo("<pre>");
print_r($rsGeoData);
echo("</pre>");

geoip_close($gi);

But $rsGeoData is always null (not an array with empty value, but really "null", i.e. is_null($rsGeoData)===null). Null is return by this function of the geoipcity.inc file :

function _get_record($gi, $ipnum)
{
    $seek_country = _geoip_seek_country($gi, $ipnum);
    if ($seek_country == $gi->databaseSegments) {
        return null;
    }
    return _common_get_record($gi, $seek_country);
}

I really can't understand why... can you help me please ?

Was it helpful?

Solution

From your file path, I'm guessing you are using a database created for unit testing rather than a full database. I'd suggest downloading a GeoLite database from MaxMind.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top