我有這樣一段代碼產生以下錯誤:庫MySQLi錯誤:addcslashes()預計2個參數,1給出
Warning: addcslashes() expects exactly 2 parameters, 1 given in line 10
我的代碼是:
$searchtype = isset($_POST['searchtype']) ? $_POST['searchtype'] : null;
$searchterm = isset($_POST['searchterm']) ? $_POST['searchtype'] : null;
$searchterm = trim($searchterm);
if (!$searchtype || !$searchterm) {
echo 'You are not entered search detail. Please go back and try again';
}
if (!get_magic_quotes_gpc()) {
$searchtype = addcslashes($searchtype);//line 10 with error
$searchterm = addcslashes($searchterm);//line with error
}
@ $db = new msqli('localhost','root','','sales');
if (mysqli_connect_errno()) {
echo 'Error: Could not connect to database. Please try again leter.';
exit;
}
ok了,問題是? – Dekel
似乎是最簡單的解決方法是隻使用'addslashes',而不是'addCslashes' ..但肯定的C版本確實需要2個參數 –
我會建議你閱讀'準備statements'並使用它。不需要'escape'和'addslashes' –