prepare($sql); $stmt->bindParam(':status', $status, PDO::PARAM_STR); $stmt->bindParam(':id', $id, PDO::PARAM_INT); // Bind the ID parameter // Execute the update if ($stmt->execute()) { // Check if the update was successful if ($stmt->rowCount() > 0) { // Trip status updated successfully jsonSuccess(null, "Trip cancelled successfully."); } else { // No rows updated, meaning the trip might not have been found or was already cancelled jsonError("No trip found to cancel."); } } else { // Print failure if the update query failed $errorInfo = $stmt->errorInfo(); error_log('SQL Error: ' . implode(", ", $errorInfo)); jsonError("Failed to cancel the trip."); } ?>