Solved

mysql query needs changing from old to new mysql?

Posted on 2009-05-17
5
206 Views
Last Modified: 2012-05-07
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
Comment
Question by:St_Aug_Beach_Bum
  • 2
  • 2
5 Comments
 
LVL 28

Accepted Solution

by:
gamebits earned 500 total points
ID: 24408191
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
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 24408229
@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
 

Author Comment

by:St_Aug_Beach_Bum
ID: 24408260
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
 
LVL 28

Expert Comment

by:gamebits
ID: 24408451
the key beside the key with the number one on your keyboard
0
 

Author Comment

by:St_Aug_Beach_Bum
ID: 24408476
`
ahh, got it!  `Thank you`!

0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question