- Replaced all client-facing $e->getMessage() with generic error messages - Added error_log() with filename prefix to all catch blocks - Covered jsonError(), echo, and json_encode() response patterns - Also fixed 2 remaining display_errors=1 and add_invoice.php leak - Script-assisted fix for 75 files, manual fix for 12 remaining edge cases
30 lines
764 B
PHP
30 lines
764 B
PHP
<?php
|
|
|
|
require_once __DIR__ . '/../../connect.php';
|
|
|
|
$driver_id = filterRequest("driver_id");
|
|
|
|
// Prepare the DELETE query
|
|
$sql = "DELETE FROM `car_locations` WHERE driver_id = :driver_id";
|
|
$stmt = $con->prepare($sql);
|
|
|
|
// Bind the driver_id parameter
|
|
$stmt->bindParam(':driver_id', $driver_id, PDO::PARAM_STR);
|
|
|
|
try {
|
|
// Execute the query
|
|
$stmt->execute();
|
|
|
|
if ($stmt->rowCount() > 0) {
|
|
// Success response
|
|
jsonSuccess(null, "Record(s) deleted successfully.");
|
|
} else {
|
|
// Failure response: no records found to delete
|
|
jsonError("No records found for the provided driver ID.");
|
|
}
|
|
} catch (PDOException $e) {
|
|
// Handle any SQL errors
|
|
jsonError("An internal error occurred. Please try again later.");
|
|
}
|
|
|
|
?>
|