輸入資料到資料庫前,最佳的過濾方式!!

以下function是當資料準備輸入到資料庫之前,將資料進行過濾的最佳方式:
(注意mysql_real_escape_string是需要在連結資料庫中才能使用)

function quote_smart($value)
{
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
// Quote if not integer
if (!is_numeric($value)) {
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}

沒有留言: