lovephp Posted April 26, 2014 Share Posted April 26, 2014 friend the following code fetches city state etc from google by zip or postcode which works fine on my localhost wamp server but when i try it online on my webhost nothing is showing, how can i fix it please? $search_code = urlencode($row['zip']); $url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . $search_code . '&sensor=false'; $json = json_decode(file_get_contents($url)); $lat = $json->results[0]->geometry->location->lat; $lng = $json->results[0]->geometry->location->lng; $address_url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=' . $lat . ',' . $lng . '&sensor=false'; $address_json = json_decode(file_get_contents($address_url)); $address_data = $address_json->results[0]->address_components; $street = str_replace('Dr', 'Drive', $address_data[1]->long_name); $town = $address_data[2]->long_name; $county = $address_data[3]->long_name; thanks Link to comment https://forums.phpfreaks.com/topic/288032-citystate-by-zip-not-working-on-webhost/ Share on other sites More sharing options...
lovephp Posted April 26, 2014 Author Share Posted April 26, 2014 ok fixed it Link to comment https://forums.phpfreaks.com/topic/288032-citystate-by-zip-not-working-on-webhost/#findComment-1477339 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.