kpetsche20 Posted July 29, 2008 Share Posted July 29, 2008 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 Quote Link to comment Share on other sites More sharing options...
stublackett Posted July 29, 2008 Share Posted July 29, 2008 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 ? Quote Link to comment Share on other sites More sharing options...
kpetsche20 Posted July 29, 2008 Author Share Posted July 29, 2008 $to = $_POST['to']; $subject = $_POST['subject']; $message = $_POST['message']; $from = $_SESSION['login']; Quote Link to comment Share on other sites More sharing options...
kpetsche20 Posted July 29, 2008 Author Share Posted July 29, 2008 Solved: Problem is "from" is an illegal column name Quote Link to comment Share on other sites More sharing options...
toivo Posted July 29, 2008 Share Posted July 29, 2008 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 Quote Link to comment Share on other sites More sharing options...
paul2463 Posted July 29, 2008 Share Posted July 29, 2008 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. Quote Link to comment Share on other sites More sharing options...
d.shankar Posted July 29, 2008 Share Posted July 29, 2008 Click "Topic Solved" if ur problem is fixed. Quote Link to comment Share on other sites More sharing options...
kpetsche20 Posted July 29, 2008 Author Share Posted July 29, 2008 Where is the topic solved button Quote Link to comment 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.