我已將我的註冊腳本從mysql轉換爲mysqli。我工作得很好像MySQL但現在給我的錯誤MySqli命令不同步;您現在無法運行此命令
Commands out of sync; you can't run this command now
這是我用來註冊用戶
function register_user($register_data) {
global $myConnection;
array_walk($register_data, 'array_sanitize');
//Make the array readable and seperate the fields from data
$fields = '`' . implode('`, `', array_keys($register_data)) . '`';
$data = '\'' . implode('\', \'', $register_data) . '\'';
//Insert the data and email an activation email to the user
mysqli_query($myConnection, "INSERT INTO `members` ($fields) VALUES ($data)") or die(mysqli_error($myConnection));
email($register_data['mem_email'], 'Activate your account', "Hello " . $register_data['mem_first_name'] . ",\n\nThank you for creating an account with H Fencing. Please use the link below to activate your account so we can confirm you identity:\n\nhttp://blah.blah.co.uk/activate.php?mem_email=" . $register_data['mem_email'] . "&email_code=" . $register_data['email_code'] . "\n\n - David & Jay ");
}
電子郵件發送罰款從我的數組的正確數據的功能。但是,沒有數據被插入到數據庫中,並且出現上述錯誤。我從來沒有遇到過這個錯誤。
1.打印出查詢,然後再運行它並查看它。 2.參數化您的查詢。 3.爲了愛上帝,請參數化您的查詢。 – Sammitch 2013-04-03 21:54:52