ganesh786 Posted November 20, 2009 Share Posted November 20, 2009 Hello Friends I have a problem in mysql insert syntax. I am using a auto increment field for user id. When i try to insert from the registration form it gives error like below. "Could not match data because 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 '@gmail.com' at line 1" Here is the query $query="INSERT INTO user(Name,Email,Password,Industry,Key)VALUES('$name','$mail','$pass','$industry','$key')"; mysql_query($query) or die('Error, insert query failed'); I have also tried inserting the Id field in the query but the same error comes. Note that i am using a auto increment field.Can anyone help?What is the right syntax when i am using a auto increment field in the insert query Thanks Link to comment https://forums.phpfreaks.com/topic/182259-mysql-insert-problem/ Share on other sites More sharing options...
rajivgonsalves Posted November 20, 2009 Share Posted November 20, 2009 if you echo out $query what does it show ? Link to comment https://forums.phpfreaks.com/topic/182259-mysql-insert-problem/#findComment-961777 Share on other sites More sharing options...
JAY6390 Posted November 20, 2009 Share Posted November 20, 2009 The problem is exactly what I was explaining in this thread just now ironically http://www.phpfreaks.com/forums/index.php/topic,277623.msg1313872.html#msg1313872 You have Key in your list of column names Put backticks around Key making it `Key` and it will work fine. Also for future reference you may want to echo mysql_error() instead of just 'Error, insert query failed' since that gives no level of detail Link to comment https://forums.phpfreaks.com/topic/182259-mysql-insert-problem/#findComment-961851 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.