WTH is wrong with this query?!?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
superwormy
Forum Commoner
Posts: 67
Joined: Fri Oct 04, 2002 9:25 am
Location: CT

WTH is wrong with this query?!?

Post by superwormy »

INSERT INTO messages SET ( toaddress = 'test@durdenwebapplications.com' , fromaddress = 'Keith Palmer &lt[semicolon]keithp@logosoftwear.com&gt[semicolon]' , ccaddress = '' , bccaddress = '' , replyaddress = 'Keith Palmer &lt[semicolon]keithp@logosoftwear.com&gt[semicolon]' , senderaddress = 'Keith Palmer &lt[semicolon]keithp@logosoftwear.com&gt[semicolon]' , subject = 'subject' , message = 'message\r\n\r\nasdgljkasdg\r\n\r\n\r\nasdg' , md5 = '6e727e1461d8ea112ebf1b570618b655' , attatchment = 0 , datetime = NOW() , ID = 0 , folder_ID = 1 , status = 9 , user_ID = 2 )

You have an error in your SQL syntax near '( toaddress = 'test@durdenwebapplications.com' , fromaddress = 'Keith Palmer &lt
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

It might be the parenthesis since the INSERT syntax you are using doesn't seem to require them:
http://www.mysql.com/doc/en/INSERT.html

Mac
User avatar
Crashin
Forum Contributor
Posts: 223
Joined: Mon May 06, 2002 3:42 pm
Location: Colorado

Post by Crashin »

Isn't SET supposed to be used with UPDATE and WHERE, and not with INSERT INTO? Ex:

Code: Select all

UPDATE messages SET ( toaddress = 'test@durdenwebapplications.com' , fromaddress = 'Keith Palmer &ltїsemicolon]keithp@logosoftwear.com&gtїsemicolon]' , etc.) WHERE id=$yourid
For INSERT INTO you would have:

Code: Select all

INSERT INTO messages (field list) VALUES (value list)
SET is used to update an existing record; INSERT INTO is used to create a new record. At least that's how I've always understood it...
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

nope, you can use SET like that. that how i prefer to do cause the field name is near the value. makes it easier for me to read.
User avatar
Crashin
Forum Contributor
Posts: 223
Joined: Mon May 06, 2002 3:42 pm
Location: Colorado

Post by Crashin »

That's good to know... :)
Post Reply