更新tinyint(1)

时间:2015-01-08 03:16:24

标签: php mysql

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

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

}

1 个答案:

答案 0 :(得分:1)

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

中的尾随逗号

MySQL会通过执行以下操作向您抛出错误:

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