If you use PHP, you can escape%, _ and characters using this code:
$escaped = addcslashes($str, "%_");
\ (backslash) and quotation marks, of course, should also escape (as always! To prevent SQL injection), for example. on mysql_real_escape_string() .
source share