I replaced the curl call with file_get_contents();
/* Replace this
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $addresstofind_1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.001 (windows; U; NT4.0; en-US; rv:1.0) Gecko/25250101');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$addr_search_1 = curl_exec($ch);
curl_close($ch);
/* With */
$addr_search_1 = file_get_contents($addresstofind_1);
then:
if(!empty($addr_search_1)){
$addr_search_1 = json_decode($addr_search_1);
if(!empty($addr_search_1->results)){
if($addr_search_1->results[0]->geometry->location){
$lon = (string)$addr_search_1->results[0]->geometry->location->lng;
$lat = (string)$addr_search_1->results[0]->geometry->location->lat;
}
}
}
it may be a bit much but if that array returns empty and with out a condition for that it will error out.