【问题标题】:geoip_record_by_addr is really and always nullgeoip_record_by_addr 确实且始终为空
【发布时间】:2014-03-19 10:59:33
【问题描述】:

我在这个脚本中使用 MaxMind GeoIP:

$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);

但 $rsGeoData 始终为空(不是具有空值的数组,而是真正的“空”,即is_null($rsGeoData)===null)。 geoipcity.inc 文件的这个函数返回 Null:

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);
}

我真的不明白为什么……你能帮帮我吗?

【问题讨论】:

    标签: php null geoip maxmind


    【解决方案1】:

    根据您的文件路径,我猜您使用的是为单元测试创​​建的数据库,而不是完整的数据库。我建议从 MaxMind 下载GeoLite database

    【讨论】:

      猜你喜欢
      • 2017-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-24
      • 1970-01-01
      • 1970-01-01
      • 2018-03-26
      • 1970-01-01
      相关资源
      最近更新 更多