<?php
// test-db-alt.php: Test DB connection with provided credentials
ini_set('display_errors', 1);
error_reporting(E_ALL);

$host = 'localhost';
$db_name = 'eiaug_marketing';
$username = 'eiaug_marketinguser';
$password = '2UFAT605IQCLmyyd';

try {
    $dsn = "mysql:host=$host;dbname=$db_name;charset=utf8mb4";
    $options = [
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        PDO::ATTR_EMULATE_PREPARES => false,
        PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8mb4"
    ];
    $pdo = new PDO($dsn, $username, $password, $options);
    $stmt = $pdo->query("SELECT NOW() as now");
    $row = $stmt->fetch();
    echo "<h2>Alternate DB Connection Test</h2>";
    echo "<p style='color:green;'>Connection successful! Server time: " . htmlspecialchars($row['now']) . "</p>";
} catch (Exception $e) {
    echo "<h2>Alternate DB Connection Test</h2>";
    echo "<p style='color:red;'>Connection failed: " . htmlspecialchars($e->getMessage()) . "</p>";
}
