1

I would like to update the status value -tinyint(1)- to activate and deactivate the user. Whenever I try to update I keep getting the message below which set to "Attendant update failed." Any help is appreciate it. Thanks

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

}
Ash23
  • 37
  • 5

1 Answers1

1

Remove the trailing comma in status = '{$status}', <=

MySQL would have thrown you an error by doing:

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

Community
  • 1
  • 1
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141