來清理用戶輸入我們通常使用mysql_real_escape_string,但例如如果我想逃跑:O'Brian它會返回O \'布萊恩,我不太喜歡這個,因爲如果我想要打印這個名字,我不得不去掉所有的時間。 所以我想使用此功能:避免MySQL注入替換單引號和雙引號
$search = array("'", '"');
$replace = array("´", "「");
$str_clean = str_replace($search, $replace, "O'Brian");
這是簡單的功能,保護我從MySQL-注入? 非常感謝,併爲我的糟糕英語感到遺憾。
Chk this它會幫你起來:http://stackoverflow.com/questions/139199/can-i-protect-against-sql-injection-by-escaping-single-quote-and-surrounding-use – 2012-03-23 10:03:04