Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
MySQL Insert Syntax Error - I Cant Find It Anywhere!
Old 12-20-2009, 04:55 AM MySQL Insert Syntax Error - I Cant Find It Anywhere!
Average Talker

Posts: 16
Name: Mark Masterson
Location: Long Island, New York
Trades: 0
I have been looking for hours for this "error" in my PHP and SQL syntax. Does anyone see anything wrong?

code:
PHP Code:
mysql_query("INSERT INTO Archive (CText, TimeStamp, By) VALUES('".$this->Temp_Send_Text ."', '".$this->TimeStamp ."', '"$this->Temp_Send_UserID ."')")
or die(
mysql_error()); 
p.s. Sorry if this is the wrong section of the forum.
__________________
Mark Masterson
MMasterson is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-20-2009, 05:21 AM Re: MySQL Insert Syntax Error - I Cant Find It Anywhere!
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
I think this is your problem:

BY is a reserved word in mysql. If you insist on using it as a table name use backticks:
PHP Code:
mysql_query("INSERT INTO Archive (CText, TimeStamp, `By`) VALUES('".$this->Temp_Send_Text ."', '".$this->TimeStamp ."', '"$this->Temp_Send_UserID ."')")
or die(
mysql_error()); 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 12-20-2009, 11:51 AM Re: MySQL Insert Syntax Error - I Cant Find It Anywhere!
Average Talker

Posts: 16
Name: Mark Masterson
Location: Long Island, New York
Trades: 0
I had thought that before, so I changed the names of the columns "From" "Text" and "Date" to "By" "CText" and "TimeStamp", but it gave me the same error. I guess I changed a reserved name to a reserved name.

It works now, thank you!
__________________
Mark Masterson
MMasterson is offline
Reply With Quote
View Public Profile
 
Old 12-20-2009, 12:50 PM Re: MySQL Insert Syntax Error - I Cant Find It Anywhere!
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
date, by, timestamp, from, text are all reserved words.

ANY word that is the name of a function, or of a column/data type is "reserved".

http://dev.mysql.com/doc/mysqld-vers...words-5-1.html
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to MySQL Insert Syntax Error - I Cant Find It Anywhere!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.53159 seconds with 12 queries