我在这里有我的代码,一旦我点击提交按钮,应该改变特定工作人员的状态。但是当我点击按钮时,它会给我一个错误的结果。谁能告诉我这是什么问题?
下面是我的代码:
if(isset($_POST['submit'])) {
$crew = 'NEW';
$query_update = "UPDATE `crew_info` SET `crew_status` = ? WHERE `id` = ?";
$stmt2 = mysqli_prepare($conn, $query_update);
mysqli_stmt_bind_param($stmt2, 'ss', $_GET['id'],$crew);
mysqli_stmt_execute($stmt2);
if (mysqli_stmt_affected_rows($stmt2) !== 0) {
echo "Crew update accepted";
} else {
echo 'Error';
}
}
答案 0 :(得分:0)
不应该使用mysqli_stmt_affected_rows来检测错误。
将您的代码更改为:
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$query_update = "UPDATE `crew_info` SET `crew_status` = ? WHERE `id` = ?";
$stmt2 = mysqli_prepare($conn, $query_update);
mysqli_stmt_bind_param($stmt2, 'ss', $_GET['id'],$crew);
mysqli_stmt_execute($stmt2);
echo "Crew update accepted";