I'm having an odd trouble updating a table in MySQL. The PHP code I've written functions just fine, but the query is having an issue. It can update the columns 'msg' and 'title', but it refuses to update a column called 'desc'. Basically, I can create an entire new row perfectly fine, but I can only update two columns for whatever reason. Any help on this issue would be greatly appreciated.
This won't work:
Code:
mysql_connect(localhost, $username, $password) or die('Error: ' . mysql_error());
mysql_select_db($database) or die('Error: ' . mysql_error());
$query = "UPDATE msgs SET title='$title', desc='$desc', msg='$msg' WHERE msg_id=$msg_id";
$result = mysql_query($query) or die ('Error: ' . mysql_error());
mysql_close();
This will work:
Code:
mysql_connect(localhost, $username, $password) or die('Error: ' . mysql_error());
mysql_select_db($database) or die('Error: ' . mysql_error());
$query = "UPDATE msgs SET title='$title', msg='$msg' WHERE msg_id=$msg_id";
$result = mysql_query($query) or die ('Error: ' . mysql_error());
mysql_close();
The error message given is:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc='ADADASDASD', msg='dfsdfsd' WHERE msg_id=14' at line 1
|