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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.