So I think in this case you need to simply encode the string you are looking for before using it in the sql query. The encoding algorithm should be the same as the one used for putting the data into the database. You will have to make sure what characters are encoded in the db so that you can use the right algorithm. Let's assume it's htmlspecialchars() with ENT_QUOTES because single quotes are encoded (if not then you can use strtr() with arrays to replace your custom list of characters with html codes). So your code would be:
PHP Code:
$Loc = "Queen's";
$Loc = htmlspecialchars($Loc, ENT_QUOTES);
// don't forget about mysql_real_escape_string!
$query = "SELECT PRODUCT_LOCATION FROM PRODUCTS WHERE (PRODUCT_LOCATION LIKE '%" .mysql_real_escape_string($Loc). "%')";
$result = mysql_query($query);
Sometimes the problem can be more complicated on web sites using a limited character set (for example ISO-8859-1), if people submit in a form characters from outside the character set range then the browser encodes them into #xx; codes so then it's not only ' and a few other characters but many more. Then that would be a bit more complicated situation if $Loc were a utf8 string with foreign characters. But I don't know what your case is no I will not go into that at the moment.
Bookmarks