From a4ba41c9c8d9b17e8fe2a7f15ba3a880dbc823a5 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Thu, 14 May 2026 19:48:26 +0300 Subject: [PATCH] Update: 2026-05-14 19:48:26 --- backend/config/db.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/backend/config/db.php b/backend/config/db.php index 4dde6c7..363a3e3 100644 --- a/backend/config/db.php +++ b/backend/config/db.php @@ -5,13 +5,9 @@ require_once __DIR__ . '/../vendor/autoload.php'; use Dotenv\Dotenv; -// Load environment variables from .env (located in the project root) -$dotenv = Dotenv::createImmutable(__DIR__ . '/../..'); -try { - $dotenv->load(); -} catch (Exception $e) { - // If .env is missing, we continue and rely on system env or defaults -} +// Load environment variables from .env (located one level above the project root) +$dotenv = Dotenv::createImmutable(__DIR__ . '/../../..'); +$dotenv->load(); $host = $_ENV['DB_HOST'] ?? 'localhost'; $dbname = $_ENV['DB_NAME'] ?? 'jordan_bot_db'; @@ -25,7 +21,7 @@ try { } catch (PDOException $e) { // In production, you should log this error and show a generic message http_response_code(500); - echo json_encode(['success' => false, 'message' => 'Database connection failed']); + echo json_encode(['success' => false, 'message' => 'Database connection failed: ' . $e->getMessage()]); exit; } ?>