Jump to content

[SOLVED] MySQL INSERT ERROR


kpetsche20

Recommended Posts

Code:

$sql2 = "INSERT INTO mailid (mailid, subject, message, from) VALUES ('".$insert."', '".$subject."', '".$message."', '".$from."')";

 

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 'from) VALUES ('4', 'et', '', 'demouser')' at line 1

Link to comment
Share on other sites

Code:

$sql2 = "INSERT INTO mailid (mailid, subject, message, from) VALUES ('".$insert."', '".$subject."', '".$message."', '".$from."')";

 

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 'from) VALUES ('4', 'et', '', 'demouser')' at line 1

 

What is the value of $insert, $subject, $message and $from ?

Link to comment
Share on other sites

Code:

$sql2 = "INSERT INTO mailid (mailid, subject, message, from) VALUES ('".$insert."', '".$subject."', '".$message."', '".$from."')";

 

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 'from) VALUES ('4', 'et', '', 'demouser')' at line 1

 

Hi,

 

from is a reserved word and you need to quote it in backticks if you want to use it as an identifier:

 

`from`

 

Regards,

toivo

Link to comment
Share on other sites

just for your information chaps and chapesses, the mysql_error() code you get back tells you exactly where the problem lies, in your case

 

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 'from) VALUES ('4', 'et', '', 'demouser')' at line 1

 

"from" is the problem, and we know this because the syntax error is always the first word after the near ', that is where the fault lies, all the rest of the line of code it gives you is so that you can easily find which word it is failing on.

 

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.