santocki
06-28-2007, 10:38 PM
I am currently developing an article script and there are Titles and Contents. To prevent sql injection, people say we must use mysql_real_escape_string().
So let's say if there is a Title that says "My Friend's best friend", if I look into the MySQL table record, the text will be saved as "My Friend\'s best friend", where the apostrophe is escaped.
Now, I am trying to create a search feature, how can I search the "Friend's" with the apostrophe? If I try to search submitting a query like:
Select * from `article` where `title` like "%Friend\'s%";
or
Select * from `article` where `title` like "%Friend's%";
both of them will not work!
Thanks in advance.
So let's say if there is a Title that says "My Friend's best friend", if I look into the MySQL table record, the text will be saved as "My Friend\'s best friend", where the apostrophe is escaped.
Now, I am trying to create a search feature, how can I search the "Friend's" with the apostrophe? If I try to search submitting a query like:
Select * from `article` where `title` like "%Friend\'s%";
or
Select * from `article` where `title` like "%Friend's%";
both of them will not work!
Thanks in advance.