Fixed JSON error handling in load-responses.php
This commit is contained in:
parent
5fcc4d0e74
commit
3c5779ce35
|
|
@ -10,16 +10,17 @@ $userToken = $_SESSION['user_token'] ?? $_GET['token'] ?? null;
|
||||||
|
|
||||||
if (!$userToken) {
|
if (!$userToken) {
|
||||||
http_response_code(403);
|
http_response_code(403);
|
||||||
echo json_encode(["error" => "Unauthorized access."]);
|
echo json_encode(["error" => "Invalid authentication token: " . htmlspecialchars($userToken)]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect to the database
|
// Connect to the database
|
||||||
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
||||||
if ($conn->connect_error) {
|
if ($conn->connect_error) {
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
echo json_encode(["error" => "Database connection failed."]);
|
echo json_encode(["error" => "Database connection failed: " . $conn->connect_error]);
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch user ID using token
|
// Fetch user ID using token
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue