Forum Moderators: coopster
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 features, in this this, how can I search the "Friend's" with the apostrophe? If I query like:
Select * from `article` where `title` like "%Friend\'s%";
or
Select * from `article` where `title` like "%Friend's%";
will not work!
Thanks in advance.
insert into article (title) values ("My Friend\\'s best friend")
instead of the correct way:
insert into article (title) values ("My Friend\'s best friend")
Generally, i prefer to turn off magic quotes and use mysql_real_escape_string(), addslashes(), etc when needed so i have more control... As far as your select statement, the first one is the safe way to do it, i.e.:
Select * from `article` where `title` like "%Friend\'s%";
Hope this helps