我浏览了论坛和帖子,但我似乎无法弄清楚我在这里做错了什么。
我首先尝试 $mysqli->num_rows 来获取受影响的行,但显然这只适用于 SELECT 语句。不幸的是, ..->affected_rows 似乎也每次都返回 0。问题是什么?
$key = $email . $password . $mysqli->mysqli_salt;
$update_password = "UPDATE `users` SET `password`=SHA1(?) WHERE `surname`=? AND `lastname`=? AND `email`=?";
$stmt_update = $mysqli->prepare($update_password);
$stmt_update->bind_param("ssss", $key, $surname, $lastname, $email);
$stmt_update->execute();
$rows = $stmt_update->affected_rows; //i've also tried '$mysqli->affected_rows;
if ($rows != 1) {
echo 'error';
}
$stmt_update->close();
谢谢!