Jump to content

[SOLVED] mySQL syntax error


eludlow

Recommended Posts

OK this is driving me totally round the bend.

 

My query is this:

 

$editQuery = mysql_query("UPDATE `membership` SET title='$title', initials='$initials', surname='$surname', address1='$address1', address2='$address2', address3='$address3', address4='$address4', county='$county', postcode='$postcode', left='$left', type='$type', email='$email', phone='$phone'  WHERE id='$toEditId'");

 

Which returns the following 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 'left='', type='Annual', email='', phone='' WHERE id='223'' at line 1

 

However, if I remove the " left='$left' " part of the query it all works fine.  The column "left" is fine, and is beign used by other queries fine...the variable $left is also fine, can be echoed no worries.  (FWIW $left = a four digit year, which is being put into a text field...so no problems there I don't think?).

 

If I use this....

 

$editQuery = mysql_query("UPDATE `membership` SET title='$title', initials='$initials', surname='$surname', address1='$address1', address2='$address2', address3='$address3', address4='$address4', county='$county', postcode='$postcode', type='$type', email='$email', phone='$phone'  WHERE id='$toEditId'");
if (!$editQuery) {
	$dbError = "An error has occured. " .  mysql_error();
	die("$dbError");
}
#die($left);

 

which has the troublesome part removed, it executs fine, and then prints the $left variable fine and then dies..as I want.

 

So what's its problem??!!

 

Any help appreciated.

 

Thanks,

Ed Ludlow

Link to comment
https://forums.phpfreaks.com/topic/54432-solved-mysql-syntax-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.