So I’m using PHP/MySQL and I have a tbl_profile table with the following fields:
loginid, venueTitle, description, address, long, lat.
You’ll have to trust me when I say that I’ve tested and had no problem updating and retrieving data from every field except long and lat. The long and lat fields are of type double and through the GUI that phpmyadmin provides I have been able to insert values and then retrieve that information but for some reason when I try to query with UPDATE I can’t seem to get it to do anything. Here are two queries, the first works and the second causes NOTHING to be updated. I printed out $longitude and $latitude just to double check that the values are correct and they print correctly. I even cast them into a doubleval to try and make sure that they are the same type as the field type in the table is. Any ideas? I’m assuming that longitude and latitude aren’t being recognized as the same type as in the table but I don’t know why that would be.
$sql = "UPDATE tbl_profile SET venueTitle='$v', description='$d', address='$a' WHERE
loginid='$username'"; // this query works
$longitude = doubleval($north);
$latitude = doubleval($east);
$sql = "UPDATE tbl_profile SET venueTitle='$v', description='$d', address='$a', long
='$longitude', lat='$latitude' WHERE loginid='$username'"; // doesn't work
longis a reserved word in MySQL. Usingmysql_error()would have pointed you to a problem atlong='<longtitude value>'.Either change your column names or wrap them in backticks in your queries, eg
Also, your code appears open to SQL injection. I’d seriously consider switching to PDO and using prepared statements with bound parameters.