You can use this -
function safe_sql($obj) { $obj = htmlspecialchars($obj); $obj = str_replace('"',""",$obj); $obj = str_replace("'","'",$obj); $obj = str_replace("`","`",$obj); $obj = mysql_real_escape_string($obj); return $obj; }
I use it and it works fine. And you can also use this function to make it normal (after pulling data from the database) -
function to_Normal($data) { $data = htmlspecialchars_decode($data); $data = str_replace(""",'"',$data); $data = str_replace("'","'",$data); $data = str_replace("`","`",$data); $data = nl2br($data); return $data; }
source share