load(); $host = $_ENV['DB_HOST'] ?? 'localhost'; $dbname = $_ENV['DB_NAME'] ?? 'jordan_bot_db'; $username = $_ENV['DB_USER'] ?? 'root'; $password = $_ENV['DB_PASS'] ?? ''; try { $pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8", $username, $password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); } 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: ' . $e->getMessage()]); exit; } ?>