左梓惠 发表于 2018-4-10 06:39:53

GeoIP 代码哪里出错了?

GeoIP 代码哪里出错了?代码源自 http://www.advertcn.com/thread-7193-1-1.htmlGeoIP.dat 是在官网下载今年的2018 GeoLite Country版本,geoip.inc和PHP文件使用的是原帖2013的 和这个有关吗?
错误提示:Parse error: syntax error, unexpected 'if' (T_IF) in /www/wwwroot/cs1/geoip/index.php on line 9
<?php
$IP = $_SERVER["REMOTE_ADDR"];
include("geoip.inc");
$gi = geoip_open("GeoIP.dat", GEOIP_MEMORY_CACHE);
$CountryCode = geoip_country_code_by_addr($gi, $IP);
geoip_close($gi);1
// ****DO NOT TOUCH ABOVE THIS LINE.******
//***Consult the Readme if you aren't sure what you're doing****
if ($CountryCode=="US"){
    //US offers go here
    header('Location: http://www.yahoo.com');
}

//Add or remove these else if statements depending on which countries you have offers for
    else if($CountryCode=="GB")
   {
      //UK offers go here
      header('Location: http://www.google.com');
    }
    else if($CountryCode=="AU")
    {
      //AU offers go here
    }
    else if($CountryCode=="DE")
    {
      //DE offers go here
      }
else {
    //Change this to reflect your international offers for country codes not listed above
    header('Location: http://www.baidu.com');
}
?>






大西瓜 发表于 2018-4-10 09:00:49

第6行,最后有个数字1删掉。
页: [1]
查看完整版本: GeoIP 代码哪里出错了?