我已经尝试调试这个错误三个多小时了,更改了文件名,尝试使用GeoIP精简版而不是GeoCity (后者需要包含一个27mb的文件,所以我认为fopen()有一个最大值),等等。
下面是我的结构文件结构:index.php -> include("configuration/config.php") - config.php -> include("inc/geo_text.php") -> geo_text.php
geo_text.php的内容是:
$ip = $_SERVER['REMOTE_ADDR'];
include("GeoIP/geoip.inc");
$gi = geoip_open("GeoIP/GeoIP.dat",GEOIP_STANDARD);
$count_name = geoip_country_name_by_addr($gi, $ip);
geoip_close($gi);
echo($count_name);现在,如果我访问geo_text.php,没有给出错误,只是为了确保我将echo($count_name)放在geo_text.php中,它会像应该的那样返回我的国家。
但是,当我运行config.php时,它返回错误:
Warning: fopen(GeoIP/GeoIP.dat) [function.fopen]: failed to open stream: No such file or directory in /nfs/c09/h02/mnt/177978/domains/domain.com/html/labs/final/configuration/inc/GeoIP/geoip.inc on line 399 Can not open GeoIP/GeoIP.dat
有没有人知道为什么会这样?
发布于 2011-08-14 06:39:38
这是一个路径问题。
geoip_open("/absolute/path/to/GeoIP/GeoIP.dat",GEOIP_STANDARD);
应该行得通。
发布于 2011-08-14 06:43:10
通过SSH连接到您的服务器并运行以下命令(假设它是一台Linux服务器):
cd /nfs/c09/h02/mnt/177978/domains/domain.com/html/labs/final/configuration/inc/GeoIP/
ls -lah然后将输出粘贴到这里以供我们查看。我的猜测是这条路并不存在。
这很奇怪。作为测试,尝试将这两个geo文件移动到与代码文件相同的目录中,然后相应地更改代码中的路径。
它正在检查domain.com中的文件,但您只是将cd输入到themeplated.com中,这就是问题所在。您的代码需要指向themeplated.com目录。
/nfs/c09/h02/mnt/177978/domains/domain.com/html/labs/final/configuration/inc/GeoIP/ /nfs/c09/h02/mnt/127878/domains/themeplated.com/html/labs/final/configuration/inc/GeoIP/
https://stackoverflow.com/questions/7053743
复制相似问题