<?php
require_once __DIR__ . '/env_loader.php';

// Report MySQLi errors automatically
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

try {
    $conn = new mysqli(
        env('DB_HOST', 'localhost'),
        env('DB_USER', 'u955643416_sthnrms'),
        env('DB_PASS', 'NRMs@165'),
        env('DB_NAME', 'u955643416_nrms')
    );
    $conn->set_charset('utf8mb4');
} catch (mysqli_sql_exception $e) {
    // Log the real error — never echo raw DB exception details to visitors.
    error_log('Database connection failed: ' . $e->getMessage());
    die('Database connection failed. Please try again shortly, or contact support if this persists.');
}
?>