Jump to content

Apostrophe in database name value causes SQL error...what to do?


Recommended Posts

I run a database that has a significant amount of apostrophe's (') as the ' in cd's.  Problem is when I run an SQL query the SQL query is interpreting the apostrophe as part of a statement and it gives me an error.  If I remove the apostrophe I don't get an error.  Any ideas on how to fix this?  I'm going to sleep on it... :P

 

Nathan 

 

"I program, therefore, I am."

 

 

 

 

rajivgonsalves  is correct. All data should be escaped before an insert/update is attempted. Use one of these functions depending on your version of MySQL:

 

http://us3.php.net/manual/en/function.mysql-real-escape-string.php

 

http://us3.php.net/manual/en/function.mysqli-real-escape-string.php

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.