I have a sql statement that is searching my database
"SELECT catelogue.ARTIST, catelogue.TITLE, catelogue.`CAT NO.`,
catelogue.FORMAT,catelogue.`IMAGE PATH`
FROM catelogue
WHERE catelogue.TITLE LIKE '%$search%'"
Now I understand in sql that your percent is your wildcard but I now need the search to search for 100% Summer because this is the title of a cd.
Is there a way to do this so that the percent sign dosn’t affect my other wildcards?
EDIT:
So if I use this
$search = addcslashes(mysql_real_escape_string($search), '%_');
Is there then any need for preg replace
$search = preg_replace("/[^a-zA-Z 0-9\/\\+\.,:?-]+/", "", $search)
And can preg replace be used in conjunction with mysql_real_escape_string?
\%is an escaped “%” character.Edited:
PHP:
in general use
string addcslashes ( string $str , string $charlist ):Don’t forget to use
string mysql_real_escape_string ( string $unescaped_string [, resource $link_identifier ] )to prevent SQL injection. So the final code might looks like: