Jump to content

Mysql insert problem


ganesh786

Recommended Posts

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

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

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.