gpt4 book ai didi

php - 更新 tinyint(1)

转载 作者:行者123 更新时间:2023-11-29 00:05:17 25 4
gpt4 key购买 nike

我想更新状态值 -tinyint(1)- 以激活和停用用户。每当我尝试更新时,我都会收到下面设置为“助理更新失败”的消息。任何帮助都很感激。谢谢

if (empty($errors)) {

// Perform Update

$id = $attendant["id"];
$status = mysql_prep($_POST["status"]);

$query = "UPDATE attendant SET ";
$query .= "status = '{$status}', ";
$query .= "WHERE id = {$id} ";
$query .= "LIMIT 1";
$result = mysqli_query($connection, $query);

if ($result && mysqli_affected_rows($connection) == 1) {
// Success
$_SESSION["message"] = "Attendant updated.";
redirect_to("activate_attendant.php");
} else {
// Failure
$_SESSION["message"] = "Attendant update failed.";
}


}
} else {
// This is probably a GET request

}

最佳答案

删除 status = '{$status}', <=

中的尾随逗号

MySQL 会抛出一个错误:

$result = mysqli_query($connection, $query) or die(mysqli_error($connection));

关于php - 更新 tinyint(1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27832351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com