PDA

View Full Version : What is wrong with this query?


MrApples
03-08-2008, 03:17 AM
This is probably something really easy that I'm an idiot for not spotting...


INSERT INTO
mylogs(
`occur`,`ip`,`ip2`,`agent`,
`refer`,`request`,`host`,`lang`,
`chars`,`encode`,`accept`,`protocol`,
`port`,`con`,`query_string`,`remote_user`,
`path_info`)
VALUES(
`1204953122`,`########`,``,`Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12`,
``,`/awesome.php`,``,`en-us,en;q=0.5`,
`ISO-8859-1,utf-8;q=0.7,*;q=0.7`,`gzip,deflate`,`text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5`,`HTTP/1.1`,
`80`,`keep-alive`,``,``,
``)

I've spent over an hour trying to figure out this syntax error. Now the MySQL claims that the column "1204953122" does not exist in 'field set'. That should be the first value.

Note: IP replaced with ####

Dismounted
03-08-2008, 03:19 AM
What's the error it's telling you?

MrApples
03-08-2008, 03:21 AM
#1054 - Unknown column '1204953122' in 'field list'
Before that it was incorrect MySQL version on line 1, I'm not sure what I did which switched the error.

MoT3rror
03-08-2008, 03:42 AM
Use `table` for defining tables and columns and 'some kind of data' for data.

yellowpinky
03-08-2008, 03:43 AM
I would try it without any single quotes (backward apostrophe) in the first half of the statement

then in the values part, use the single quote ' character instead of the ` backward apostrophe.

MrApples
03-08-2008, 03:52 AM
I would try it without any single quotes (backward apostrophe) in the first half of the statement

then in the values part, use the single quote ' character instead of the ` backward apostrophe.
I'm shocked but that worked, thanks.

Dismounted
03-08-2008, 04:00 AM
You only really need to use backticks (`) if you're using reserved MySQL keywords.