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 Link to comment https://forums.phpfreaks.com/topic/117144-solved-mysql-insert-error/ 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 ? Link to comment https://forums.phpfreaks.com/topic/117144-solved-mysql-insert-error/#findComment-602495 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']; Link to comment https://forums.phpfreaks.com/topic/117144-solved-mysql-insert-error/#findComment-602496 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 Link to comment https://forums.phpfreaks.com/topic/117144-solved-mysql-insert-error/#findComment-602498 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 Link to comment https://forums.phpfreaks.com/topic/117144-solved-mysql-insert-error/#findComment-602500 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. Link to comment https://forums.phpfreaks.com/topic/117144-solved-mysql-insert-error/#findComment-602504 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. Link to comment https://forums.phpfreaks.com/topic/117144-solved-mysql-insert-error/#findComment-602505 Share on other sites More sharing options...
kpetsche20 Posted July 29, 2008 Author Share Posted July 29, 2008 Where is the topic solved button Link to comment https://forums.phpfreaks.com/topic/117144-solved-mysql-insert-error/#findComment-602536 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.