Results 1 to 5 of 5
Sep 9, 2011, 05:37 #1
- Join Date
- Jun 2005
- Kennett Square, PA USA
- 0 Post(s)
- 0 Thread(s)
mysql search string contains apostrophe
I'm having a hard time creating a query that searches for database content that contains single quotes, or apostrophe characters.
I use mysql_real_escape_string on the data prior to putting it into the db. Then I have a search form where the user can enter a word or phrase.
If the user searches for "Mayor's" it is not found because the apostrophe is escaped in the db. (When I look directly in the database using phpMyAdmin, I can see that the value is Mayor\'s)
So, the question in a nutshell is: what's the best way to allow a user to search the database for values that contain an apostrophe, or a quotation mark, or any other character that would have been escaped by mysql_real_escape_string?
Incidentally, the user's search string also is cleaned with mysql_real_escape_string, just to further complicate things.