Salve,
ho uno script che mi fa la conversione da indirizzi a coordinate e poi mi dovrebbe scrivere tali coordinate in
---------------------------------------------------------
id | address | city | state | zip | lat | lng|
---------------------------------------------------------
2 | via toledo | napoli | IT | 80121 | | |
ed ho il seguente codice che mi dovrebbe mettere i miei valori in lat e lng:
// save latitude and longitude to the database
function saveLatLng($latLngArray) {
include 'config.php';
connectToDatabase();
$geocodedToSave = explode(",",$latLngArray);
$latitudeToSave = $geocodedToSave[2];
$longitudeToSave = $geocodedToSave[3];
$indexToSaveTo = $geocodedToSave[0];
$addressToSaveTo = $geocodedToSave[1];
$result = mysql_query('UPDATE ' . $table .
' SET `' . $latitude . '`=' . $latitudeToSave . ', `' . $longitude . '`=' . $longitudeToSave .
' WHERE `' . $index . '`=' . $indexToSaveTo . ';');
return 'ROWID: ' . $indexToSaveTo .
', ADDRESS: ' . $addressToSaveTo .
', LATITUDE: ' . $latitudeToSave .
', LONGITUDE: ' . $longitudeToSave;
}
il config.php è questo:
<?php
/************************************************** ********
* mysql-table-geocode config file
* THIS IS THE ONLY FILE YOU SHOULD EDIT
* EDITING OTHER FILES MAY LEAD TO DANGERRRRR
************************************************** ********/
/* update info to connect to database */
$host = 'localhost';
$username = 'root';
$password = 'password';
$database = 'prova';
$table = 'table';
/**
* enter the field names from $table
* which correspond to the table and address info
*/
$index = 'ID';
$street = 'address';
$city = 'city';
$state = 'state';
$zip = 'zip';
/**
* if you have one field for the full address, then
* uncomment the following line and replace the address
* with the name of that column in your table
*/
//$fullAddress = '123 Mockingbird Lane New York, NY 90210';
/** if you do not have latitude or longitude
* columns in your table, create them duh
*/
$latitude = 'lat';
$longitude = 'lng';
/**
* Enter your own Google Maps API here
* for more info, go here: https://developers.google.com/maps/
*/
$googleMapsAPI = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
?>
Il mio problema è che non riesco a scrivere quei valori all'interno del database.