Litlle correction :
Main Topics
Browse All TopicsI'm pulling data from one table in my database and inserting it into another table. All goes well until I come across a field in my "pull" table that has an apostrophe in it. I then receive the following error: 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 'Connell','Redmond','Open'
The offending field in the above referenced error is 'Connell' which is actually 'O'Connell'. How do I get rid of the apostrophe when I'm pulling the data, then reinsert it when I'm posting to the new table?
I've included a snippet of my code below.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
When you bring in data with apostrophes (and some other things) you MUST escape it with mysql_real_escape_string()
This makes sure the data can be put into the data base, and the resulting data field contains EXACTLY what you started with, ie, "O'Connell" When you retrieve this field you get back "O'Connell" and as you can see it has an apostrophe. So you must run it through mysql_real_escape_string()
There are a couple of other wrinkles to consider. Be on the lookout for "magic quotes" - you DO NOT want this set on. Ask your host to turn it off. It can cause you to get backslashes in your data base. If you have got those already, you need to run a little script to get rid of them. And choose mysql_real_escape_string()
best regards, ~Ray
Business Accounts
Answer for Membership
by: leakim971Posted on 2009-11-03 at 16:05:58ID: 25735261
Hello sully1958,
Fast resolution, use " instead of '
Select allOpen in new window