Hi, this below php coding is not working and the browser gives error <?php function locateIp($ip){ $ip = $_SERVER['REMOTE_ADDR']; $xmldata = 'www.api.ipinfodb.com/v3/ip-country/?key=0ce7f3d044df78597ce89d651afbce43cc852c5b4be15b28cf37549cb8fd832f&ip=$ip'; $open = fopen($xmldata, 'r'); $content = stream_get_contents($open); $data = explode(";",$content); return $data; } $ip_data = locateIp($ip); if($ip_data[3] == "IN"){ header('Location: http://www.webhostingleader.com/client/cart.php?currency=5');} else{ header('Location: http://www.webhostingleader.com/client/cart.php?currency=1');} ?> browser gives following error Warning: fopen(www.api.ipinfodb.com/v3/ip-country/?key=0ce7f3d044df78597ce89d651afbce43cc852c5b4be15b28cf37549cb8fd832f&ip=$ip) [function.fopen]: failed to open stream: No such file or directory in /home/web1host/public_html/currency.php on line 6 Warning: stream_get_contents() expects parameter 1 to be resource, boolean given in /home/web1host/public_html/currency.php on line 7 Warning: Cannot modify header information - headers already sent by (output started at /home/web1host/public_html/currency.php:6) in /home/web1host/public_html/currency.php on line 24 Any help to correct this error will be greatly appreciated.
When your posting codes here on DP choose the advanced mode and select the php tags, anyway heres your solution $xmldata = 'http://www PHP: You neglected to include http://
Hi, I included http:// still it gives below error Warning: fopen() [function.fopen]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/web1host/public_html/currency.php on line 6 Warning: fopen(http://www.api.ipinfodb.com/v3/ip-country/?key=0ce7f3d044df78597ce89d651afbce43cc852c5b4be15b28cf37549cb8fd832f&ip=$ip) [function.fopen]: failed to open stream: no suitable wrapper could be found in /home/web1host/public_html/currency.php on line 6 Warning: stream_get_contents() expects parameter 1 to be resource, boolean given in /home/web1host/public_html/currency.php on line 7 Warning: Cannot modify header information - headers already sent by (output started at /home/web1host/public_html/currency.php:6) in /home/web1host/public_html/currency.php on line 24
This new error "allow_url_fopen=0" is a problem with your host, if you have access to php.ini you can just add the line allow_url_fopen = 1 Code (markup): or allow_url_fopen = On Code (markup):
The answer is stated, you have no permission (or php) to include external data. So email your hosting company or alter php.ini
do you host your own site or is it hosted by a company? if 1, search your computer lol if 2, contact your hosting company!
Is your host web1host.net ? according there FAQ you can create your own php.ini file to override previously set values So you simple create a php.ini file and enter the content as above allow_url_fopen = 1 or allow_url_fopen = On ////Before I confuse you its possible that you might need to rename the php.ini to php4.ini or php5.ini , best to see what your host advises first.