Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

mysql query needs changing from old to new mysql?

I'm moving from a server with an old version of mysql 3.23.58  to a newer version, 5.0.45

In my php scripts, I have a query like this:

INSERT INTO oys_reports (city,code,condition,f,c) VALUES ('Baltimore IH','NAMD','na','61','16.1')

which doesn't seem to work with mysql 5, I just get a syntax error.

Is there a different way to do the same thing now?

Thanks,    Chris
0
St_Aug_Beach_Bum
Asked:
St_Aug_Beach_Bum
  • 2
  • 2
1 Solution
 
gamebitsCommented:
condition is a reserved word enclosed it between bactick `

INSERT INTO oys_reports (`city`, `code`, `condition`, `f`, `c`) VALUES ('Baltimore IH','NAMD','na','61','16.1')

0
 
Ray PaseurCommented:
@gamebits: Nice Catch!  To avoid accidentally using a MySQL reserved word in my queries, I like to name columns like o_city, o_code, o_condition, etc.
0
 
St_Aug_Beach_BumAuthor Commented:
All Right!  Thank you!

Gamebits gets the points, but thanks for the additional tidbit Ray.

Now for the stupid follow up question.  I'm going to copy the code and paste it in to fix this, but for the future, where are backticks on my keyboard?   Or do you just make them up with some kind of magic?
0
 
gamebitsCommented:
the key beside the key with the number one on your keyboard
0
 
St_Aug_Beach_BumAuthor Commented:
`
ahh, got it!  `Thank you`!

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now