从PHP5(Windows)调用MAXMIND geoip.dat时出现意外字符/T_字符串错误

从PHP5(Windows)调用MAXMIND geoip.dat时出现意外字符/T_字符串错误,php,maxmind,Php,Maxmind,我在尝试从示例PHP脚本调用MAXMIND的geoip.dat时遇到了一个奇怪的错误- Geoip.dat是一个二进制文件,必须单独下载。请注意,还有一个CSV版本我没有使用 我的代码与示例脚本几乎完全相同,只是路径不同: <?php // This code demonstrates how to lookup the country by IP Address include("GeoIP.dat"); // Uncomment if querying against GeoIP

我在尝试从示例PHP脚本调用MAXMIND的geoip.dat时遇到了一个奇怪的错误-

Geoip.dat是一个二进制文件,必须单独下载。请注意,还有一个CSV版本我没有使用

我的代码与示例脚本几乎完全相同,只是路径不同:

<?php

// This code demonstrates how to lookup the country by IP Address

include("GeoIP.dat");

// Uncomment if querying against GeoIP/Lite City.
// include("geoipcity.inc");

$IPaddress=$_SERVER['REMOTE_ADDR'];

$gi =
geoip_open("C:\Inetpub\wwwroot\clients\geoip\GeoIP.dat",GEOIP_STANDARD);

echo geoip_country_code_by_addr($gi, $IPaddress) . "\t" .
geoip_country_name_by_addr($gi, $IPaddress) . "\n";
echo geoip_country_code_by_addr($gi, $IPaddress) . "\t" .
geoip_country_name_by_addr($gi, $IPaddress) . "\n";

geoip_close($gi);

?>

GeoIP.dat
不是PHP文件,因此不能使用
include
语句包含它。改为包含
geoip.inc
(无论在哪里),你的代码应该可以工作。

谁说你应该
包含
这个.dat文件?!如果他们这样做了,那就是胡说八道。
<?php

// This code demonstrates how to lookup the country by IP Address

include("GeoIP.dat");

// Uncomment if querying against GeoIP/Lite City.
// include("geoipcity.inc");

$IPaddress=$_SERVER['REMOTE_ADDR'];

$gi =
geoip_open("C:\Inetpub\wwwroot\clients\geoip\GeoIP.dat",GEOIP_STANDARD);

echo geoip_country_code_by_addr($gi, $IPaddress) . "\t" .
geoip_country_name_by_addr($gi, $IPaddress) . "\n";
echo geoip_country_code_by_addr($gi, $IPaddress) . "\t" .
geoip_country_name_by_addr($gi, $IPaddress) . "\n";

geoip_close($gi);

?>
PHP Version 5.2.6

System  Windows NT 5.2 build 3790
Build Date  May 2 2008 18:01:20
Configure Command   cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared" "--with-extra-includes=C:\Program Files (x86)\Microsoft SDK\Include;C:\PROGRA~2\MICROS~2\VC98\ATL\INCLUDE;C:\PROGRA~2\MICROS~2\VC98\INCLUDE;C:\PROGRA~2\MICROS~2\VC98\MFC\INCLUDE" "--with-extra-libs=C:\Program Files (x86)\Microsoft SDK\Lib;C:\PROGRA~2\MICROS~2\VC98\LIB;C:\PROGRA~2\MICROS~2\VC98\MFC\LIB"
Server API  ISAPI
Virtual Directory Support   enabled
Configuration File (php.ini) Path   C:\WINDOWS
Loaded Configuration File   C:\Parallels\Plesk\Additional\PleskPHP5\php.ini
PHP API 20041225
PHP Extension   20060613
Zend Extension  220060519
Debug Build no
Thread Safety   enabled
Zend Memory Manager enabled
IPv6 Support    enabled
Registered PHP Streams  php, file, data, http, ftp, compress.zlib, https, ftps
Registered Stream Socket Transports tcp, udp, ssl, sslv3, sslv2, tls
Registered Stream Filters   convert.iconv.*, string.rot13, string.toupper, string.tolower,