michaela
michaela

Reputation: 171

error in mysql statement

I cannot figure this one out. All the variables are ok. Printed out the sql statement before executing in php... This is the statement exactly as it is sent to be ran by php

INSERT INTO 'images' ('filename', 'creator', 'date', 'notes') VALUES ('cat.sdf', 'michaelamici', '2002-07-05', 'SDfdddfdffddffdfgs')

Thank You!

Upvotes: 1

Views: 47

Answers (3)

Michael
Michael

Reputation: 12836

You're enclosing the table/field names in single-quotes. You need to do it with back-ticks (or nothing, depending on the name).

INSERT INTO `images` (`filename`, `creator`, `date`, `notes`) VALUES ('cat.sdf', 'michaelamici', '2002-07-05', 'SDfdddfdffddffdfgs')

Just in case you're interested, a list of reserved names (which must be quoted if used as a table or column name) can be found here: http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html.

Also, to find out what characters may be included in an unquoted name and which can appear only as part of a quoted name, see here: http://dev.mysql.com/doc/refman/5.5/en/identifiers.html.

N.B. the relevant MySQL version.

Upvotes: 5

sujal
sujal

Reputation: 1050

INSERT INTO `images` (`filename`, `creator`, `date`, `notes`) VALUES
 ('cat.sdf', 'michaelamici', '2002-07-05', 'SDfdddfdffddffdfgs');

Try editing single quotes to backquotes for table name and field names

Upvotes: 1

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799430

Your table and field names should either be in backquotes (`) or unquoted.

Upvotes: 2

Related Questions