2014-03-19 37 views
0

我使用的MaxMind GeoIP的這個腳本:geoip_record_by_addr是真的,總是空

$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文件的此功能:

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

我真的不明白,爲什麼......你能幫助我嗎?

回答

1

從你的文件路徑,我猜你正在使用爲單元測試而不是完整的數據庫創建的數據庫。我建議從MaxMind下載GeoLite database