Page 1 of 1

php explode, foreign characters leak through

Posted: Fri Aug 14, 2009 9:39 pm
by gth759k
I have a simple search engine and I'm trying to detect certain words in a string with something like this:

Code: Select all

 
$sql = "SELECT * FROM table_links WHERE title like('%" . $search . "%')";
 
but somehow anything in the database that is a foreign character or html symbol like "»" seems to find its way into the results even if the title doesn't contain the $search phrase. Does anyone know a method to strip all those things from the text before it gets to my query? Any help would be appreciated. Thanks.

Re: php explode, foreign characters leak through

Posted: Fri Aug 14, 2009 10:22 pm
by aceconcepts
This is becauase the % wildcard matches a given pattern in a string. You have not specified that you don't want any receive any other characters that may be in a string.