htmlentities() solo te servira para ataques xss... no te va a salvar de inyecciones sql....
para inyecciones sql debes usar alguna funcion como esta:
Código PHP:
<?php
function antisqlinyection($theValue,$longitudmax) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
$theValue = strip_tags($theValue);
$theValue = substr($theValue, 0, $longitudmax);
$theValue = htmlentities($theValue);
return $theValue;
}
?>