'error', 'message' => 'All fields are required.']); exit; } // Ensure correct format for MySQL TIME column compatibility if (strlen($timeFrom) === 5) $timeFrom .= ':00'; if (strlen($timeTo) === 5) $timeTo .= ':00'; try { $stmt = $pdo->prepare("UPDATE room_restrictions SET day_of_week = ?, time_from = ?, time_to = ? WHERE id_restriction = ?"); $result = $stmt->execute([$day, $timeFrom, $timeTo, $id]); if ($result) { echo json_encode(['status' => 'success', 'message' => 'Restriction updated successfully.']); } else { echo json_encode(['status' => 'error', 'message' => 'Failed to update: ' . implode(' ', $stmt->errorInfo())]); } } catch (Exception $e) { echo json_encode(['status' => 'error', 'message' => 'Exception: ' . $e->getMessage()]); }