Reputation: 413
So I have the following code, I have made sure that both the variables have something stored in them, by echoing the results in both $lat
and $long
$lat = $latitude;
$updatelat = mysql_query("UPDATE listings SET lat='". $lat ."' WHERE id='". $id ."'");
$long = $longitude;
$updatelong = mysql_query("UPDATE listings SET long='". $long ."' WHERE id='". $id ."'");
The $updatelat
query works absolutely perfect, and the value is set in the database.
The $updatelong
query however doesn't work, but there is definitely a value stored in $long
Can anyone see something obviously wrong with this code? There is definitely a column called long
in my database. I am completely confused.
Upvotes: 0
Views: 598
Reputation: 413
Simple fix for this
If queries such as this don't work:
$updatelat = mysql_query("UPDATE listings SET lat='". $lat ."' WHERE id='". $id ."'");
There is probably a clash with MySQL reserved keywords, so try using backticks
$updatelat = mysql_query("UPDATE listings SET `lat`='". $lat ."' WHERE `id`='". $id ."'");
and it works!
Upvotes: 0
Reputation: 1033
Why 2 queries? You can do it in one as the id is same.
$lat = $latitude;
$long = $longitude;
$updatelatlong = mysqli_query($connection, "UPDATE listings SET lat='". $lat ."',long='". $long ."' WHERE id='". $id ."'");
Upvotes: 1
Reputation: 1294
Do you do this $result = mysqli_query($con,$updatelong);
? It'd be helpfull to see more of your code than this little part
Upvotes: 0