eludlow Posted June 6, 2007 Share Posted June 6, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/54432-solved-mysql-syntax-error/ Share on other sites More sharing options...
Wildbug Posted June 6, 2007 Share Posted June 6, 2007 Can you print the query string as generated (save to a var and print -- one that causes an error) and post a "DESCRIBE membership"? Quote Link to comment https://forums.phpfreaks.com/topic/54432-solved-mysql-syntax-error/#findComment-269191 Share on other sites More sharing options...
eludlow Posted June 6, 2007 Author Share Posted June 6, 2007 Done it! Turns out left is a mySQL function...so.... `left` = '$left' does the trick Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/54432-solved-mysql-syntax-error/#findComment-269218 Share on other sites More sharing options...
fenway Posted June 6, 2007 Share Posted June 6, 2007 Done it! Turns out left is a mySQL function...so.... `left` = '$left' does the trick Thanks! Not a function, a reserved keyword... as in "LEFT JOIN". Quote Link to comment https://forums.phpfreaks.com/topic/54432-solved-mysql-syntax-error/#findComment-269412 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.