roseplant Posted April 18, 2006 Share Posted April 18, 2006 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 ( " Quote Link to comment https://forums.phpfreaks.com/topic/7785-whats-wrong-with-this/ Share on other sites More sharing options...
fenway Posted April 19, 2006 Share Posted April 19, 2006 I'm not sure -- looks syntactially correct, hard to see what the problem might be. Quote Link to comment https://forums.phpfreaks.com/topic/7785-whats-wrong-with-this/#findComment-28564 Share on other sites More sharing options...
jworisek Posted April 19, 2006 Share Posted April 19, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/7785-whats-wrong-with-this/#findComment-28717 Share on other sites More sharing options...
fenway Posted April 20, 2006 Share Posted April 20, 2006 [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... Quote Link to comment https://forums.phpfreaks.com/topic/7785-whats-wrong-with-this/#findComment-29107 Share on other sites More sharing options...
roseplant Posted April 21, 2006 Author Share Posted April 21, 2006 That was the problem - changed dashes to underscores and it worked, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/7785-whats-wrong-with-this/#findComment-29389 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.