I have this function I’m using and I want to be sure that it fully protects against SQL injection attacks:
function MakeSafeForQuery($string)
{
// replace all of the quote
// chars by their escape sequence
$ret = str_replace("\\","\\\\",$string);
$ret = str_replace("'","\\'",$ret);
$ret = str_replace("\"","\\\"",$ret);
return $ret;
}
Am I missing anything serious?
Edit: I’m using MySQL by the way.
http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-escape-string