Jump to content

Archived

This topic is now archived and is closed to further replies.

tomfmason

simple mysql problem

Recommended Posts

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', 'test3@test1.com', '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 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
ok thanks. I knew it was something simple..lol

Share this post


Link to post
Share on other sites

×

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.