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