# PHP, mySQL and Apostrophes

**URL:** <https://forum.kirupa.com/t/php-mysql-and-apostrophes/261069>\
**Category:** programming\
**Created:** [May 22, 2008, 8:22pm UTC](https://forum.kirupa.com/t/php-mysql-and-apostrophes/261069 "2008-05-22T20:22:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sceneshift](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sceneshift](https://forum.kirupa.com/u/sceneshift)\
**Post date:** [May 22, 2008, 8:22pm UTC](https://forum.kirupa.com/t/php-mysql-and-apostrophes/261069/1 "2008-05-22T20:22:36Z")

</div>

I am trying to setup a search function using the “LIKE %$var%” method, but I have run into a problem.

The data in the database is like so: “Person’s Item”

If I search “Person’s Item” the data is retrieved successfully.

If I search “Persons Item” without an apostrophe, the retrieval is unsuccessfully.

Is there any way to get mySQL to ignore apostrophes both on the user and database side? so either of the above examples can be entered and successful?

---

<div class="post-metadata">

**Author:** ![borrob](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@borrob](https://forum.kirupa.com/u/borrob)\
**Post date:** [May 26, 2008, 9:19am UTC](https://forum.kirupa.com/t/php-mysql-and-apostrophes/261069/2 "2008-05-26T09:19:18Z")

</div>

You can use escape characters in the statament so this should work:

like ‘%person’s%’
