Jump to content


Photo

what's wrong with this?


  • Please log in to reply
4 replies to this topic

#1 roseplant

roseplant
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 18 April 2006 - 10:20 PM

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

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


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 ( "

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 19 April 2006 - 01:46 PM

I'm not sure -- looks syntactially correct, hard to see what the problem might be.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 jworisek

jworisek
  • Members
  • PipPipPip
  • Advanced Member
  • 112 posts

Posted 19 April 2006 - 07:20 PM

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.

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 20 April 2006 - 07:05 PM

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 ‘$’.
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...
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 roseplant

roseplant
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 21 April 2006 - 05:48 PM

That was the problem - changed dashes to underscores and it worked, thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users