tomfmason Posted July 21, 2006 Share Posted July 21, 2006 lol. I feel dumb for even asking this but I am ??? at this point. ok here we go. I am attempting to insert some information into a database.(php 101 all over again)here is the code[code=php:0]$sql = mysql_query("INSERT INTO chat (first_name, last_name, email, department, status, chat_date, chat_time, chat_text, from) VALUES ('$first_name', '$last_name', '$email', '$department', '$status', now(), now(), '$chat_text', '$from')") or die(mysql_error());[/code]This is the mysql error that I get. [code]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 ('testguy', 'test', '[email protected]', 'Support', 'waiting'' at line 1[/code]I am sure that this is a simple error but it is hanging me up. When I erase [b]from[/b] from the query, it inserts just fine.Any suggestions would be great.thanks,tom Link to comment https://forums.phpfreaks.com/topic/15294-simple-mysql-problem/ Share on other sites More sharing options...
ryanlwh Posted July 21, 2006 Share Posted July 21, 2006 because "from" is a keyword, mysql is acting up on it. try to surround it with backticks(`), or just change the column to a different name. Link to comment https://forums.phpfreaks.com/topic/15294-simple-mysql-problem/#findComment-61853 Share on other sites More sharing options...
tomfmason Posted July 21, 2006 Author Share Posted July 21, 2006 ok thanks. I knew it was something simple..lol Link to comment https://forums.phpfreaks.com/topic/15294-simple-mysql-problem/#findComment-61854 Share on other sites More sharing options...
ryanlwh Posted July 21, 2006 Share Posted July 21, 2006 you're welcome. sometime i got caught in this error too Link to comment https://forums.phpfreaks.com/topic/15294-simple-mysql-problem/#findComment-61856 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.