dsutuyxe088689
2014-03-19 10:59
浏览 74
已采纳

geoip_record_by_addr实际上始终为null

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 ?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dsgsdg206050 2014-03-19 13:30
    已采纳

    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.

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题