2012-12-30 23 views
0
$location = "http://www.geoplugin.net/php.gp?ip=115.67.131.206"; 
$geoplugin = unserialize(file_get_contents($location)); 
$country = $geoplugin['geoplugin_countryName']; 
$city  = $geoplugin['geoplugin_city']; 

我在IIS上运行上面的PHP代码(来自Geoplugin的一个例子),它完美地工作,返回国家&城市;但是,从公共托管服务器运行时,不会返回任何内容,也不会显示错误。我错过了什么?PHP geoplugin在公共服务器上失败

+0

东西检查配置http://php.net /manual/en/filesystem.configuration.php#ini.allow-url-fopen –

+0

在开始处添加此代码并再次运行。 '的error_reporting(-1); ini_set('display_errors',1); ini_set('display_startup_errors',1);'你会看到错误 –

回答

0

查找php.ini文件服务器上,然后找了allow_url_fopen使其

allow_url_fopen = On 

请让我们知道,如果这个解决您的问题,否则

+0

我刚刚检查过服务器,并被告知远程连接不被允许,所以推测这是原因?我没有访问php.ini文件。 – Archdeacon

+0

我认为与共享主机,你仍然可以拥有自己的php.ini文件,请尝试在根文件夹中创建php.ini文件添加一些配置以检查服务器是否可以看到它,然后添加allow_url_fopen = On然后 – Omiga