Solved

mysql query needs changing from old to new mysql?

Posted on 2009-05-17
5
204 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 108

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now