Jump to content


Photo

simple mysql problem


  • Please log in to reply
3 replies to this topic

#1 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 21 July 2006 - 10:04 PM

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

$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());

This is the mysql error that I get.

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

I am sure that this is a simple error but it is hanging me up. When I erase  from from the query, it inserts just fine.

Any suggestions would be great.

thanks,
tom 

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#2 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 21 July 2006 - 10:06 PM

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.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#3 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 21 July 2006 - 10:07 PM

ok thanks. I knew it was something simple..lol

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#4 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 21 July 2006 - 10:08 PM

you're welcome. sometime i got caught in this error too
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users