1

Attempting to geolocate country and region via GeoIP Module / MaxMind DB.

Double checked it's loaded via phpinfo():

 geoip
 geoip support  enabled
 geoip extension version    1.0.8
 geoip library version  1004005

Double checked the DB:

    <?
    $db = geoip_database_info();
    print_r($db);
    ?>

Returns:

GEO-106FREE 20090201 Build 1 Copyright (c) 2007 MaxMind LLC All Rights Reserved

But when I try this:

<?
$record = geoip_record_by_name("76.109.14.196");
if ($record) {
   print_r($record);
}
?>

It turns up blank.

Is there a piece I'm missing?

4

2 回答 2

0

数据库可能已过时。为什么不使用已正确更新的远程解决方案,例如http://www.geoplugin.net/

简单示例

$xml = simplexml_load_file("http://www.geoplugin.net/xml.gp?ip=76.109.14.196");
echo $xml->geoplugin_countryName ;

输出

 United States
于 2012-08-18T13:54:07.977 回答
0

可能未安装用于位置查找的特定数据库。尝试geoip_country_code_by_name,它应该工作。

于 2013-05-23T01:27:09.987 回答