Jump to content

Archived

This topic is now archived and is closed to further replies.

roseplant

what's wrong with this?

Recommended Posts

Am I retarded or just tired? Why is this query returning an error?

[code]INSERT INTO stats (visit-date,visit-ip,visit-refer,visit-page,visit-useragent) values (NOW(),'134.226.111.111','','/scripts/stats.php','Mozilla');[/code]

phpadmin says: "#1064 - 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 '-date,visit-ip,visit-refer,visit-page,visit-useragent) values ( "

Share this post


Link to post
Share on other sites
I'm not sure -- looks syntactially correct, hard to see what the problem might be.

Share this post


Link to post
Share on other sites
I could be wrong but I don't think it likes you using dashes as column names. That could explain why it is failing at the first - in the query. Try either putting the column names in back ticks or changing the dashes to underscores.

Share this post


Link to post
Share on other sites
[code]Database, table, index, column, and alias names are identifiers. If an identifier is a reserved word or contains special characters, you must quote it whenever you refer to it. Special characters are those outside the set of alphanumeric characters from the current character set, ‘_’, and ‘$’. [/code]
Good call... I had no idea, since I always use underscores at a matter of habit. Funny that you can use a dollar sign, though! Guess using operators in identifiers is always a bad idea...

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.