Update: 2026-05-14 19:48:26
This commit is contained in:
@@ -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 {
|
||||
// Load environment variables from .env (located one level above the project root)
|
||||
$dotenv = Dotenv::createImmutable(__DIR__ . '/../../..');
|
||||
$dotenv->load();
|
||||
} catch (Exception $e) {
|
||||
// If .env is missing, we continue and rely on system env or defaults
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user