Reputation: 23
This is my code bellow:
$ip_data = json_decode(file_get_contents("http://geoplugin.net/json.gp?ip=119.82.67.243"));
echo "<pre>";
print_r($ip_data);
die;
When I run this 2 different on 1 system its ok but on second system its giving error
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: No such host is known
I have already checked allow_url_fopen=On
is on both system so please suggest some other soln...thanks
Upvotes: 2
Views: 8240
Reputation: 338
If there is a problem with dns on second environment you can do this:
<?php
echo gethostbyname("ONLY_ HOST_HERE_WITHOUT_HTTP_PROTOCOL"); // debug
var_export (dns_get_record ( "ONLY_HOST_HERE_WITHOUT_HTTP_PROTOCOL") ); ?>
and you can change your dns servers:
$dns=array("194.204.159.1","194.204.152.34","8.8.8.8","8.8.4.4"); // or you can pass DNS from your first machine :)
var_export (dns_get_record ( "ONLY_ HOST_HERE_WITHOUT_HTTP_PROTOCOL" , DNS_ALL , $dns ));
Upvotes: 1