sembra che non ti funzioni... fai un echo mysql_real_escape_string(htmlentities($stringa)); e dicci cosa ti restituisce?