Like Operator in mysql with Escape Characters

By | December 13, 2013

To Address LIKE quandary, a custome escaping mechanism must convert user-supplied % and _ characters to literals.Use addcslashes(), a function the let’s you specify a character range tot escape

For Examples

$mydoubts=addcslashes(mysql_real_escape_string(“%something_”),”%_”);
//$mydoubts=\%something\_
mysql_query(“SELECT * From messages where subject LIKE ‘{$mydoubts}%'”);