$url = 'http://maps.google.com/maps/geo?q='.str_replace(" ","",$postcode[$z]).',+UK&output=csv&sensor=false';
$data = @file_get_contents($url);
echo $data;
$result = explode(",", $data);
$lat = (float) $result[2]; // latitude
$lon = (float) $result[3]; // longitude;
echo '<br>Latitude: '.$lat;
echo '<br>Longitude: '.$lon;
$wpresult = $wpdb->insert("buss_add",array(
"buss_id" => $buss_id,
"add1" => $add1[$z],
"add2" => $add2[$z],
"city" => $city[$z],
"county" => $county[$z],
"postcode" => $postcode[$z],
"country" => $country[$z],
"tel" => $tel[$z],
"lat" => $lat,
"lon" => $lon
),array(
"%d","%s","%s","%s","%s","%s","%s","%s","%f","%f"
));
Despite this being right, and even with typecasting the lat and lon variables this does not seem to want to go into the database as a float. I think wordpress $wpdb is to blame. Anyone got any ideas?
To also confirm the database looks like this, which should be absolutely fine – http://cl.ly/421m2K3F2k3p3X1D3V1v
An example of the values below:
Latitude: 51.7191557
Longitude: 0.6665619
assuming
$latis a string and$zis some number, then$lat[$z]is one char in that string, shouldn’t you just use"lat" => $lat?