Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi all
I am trying to write a search query to search my MYSQL database and it works perfectly except if the search string contains an apostrophe
I have checked the database and the search terms are stored with slashes added
eg can't is stored as can\'tNow no matter how I manipulate my query I cannot get results for those search terms that contain apostrophes, it just returns "no products found"
the query I use is
'select * from product where prod_search_term like "%'.$keyw.'%"'
I have tried adding slashes to the $keyw variable but that doesn't make a difference
Any help would be appreciated

No worries
fixed it
used the below
$keyw = str_replace("\'", "\\\\'", $keyw);
$keyw = addslashes($keyw);I think my server may have had magic quotes on

![]() |
Java - Order of files in ...
|
IE message
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |