<?php
// test_db_connection.php
error_reporting(E_ALL);
ini_set('display_errors', 1);

try {
    require_once __DIR__ . '/db.php'; // Make sure this path is correct relative to test_db_connection.php
    $stmt = $pdo->query('SELECT 1'); // Simple query to test connection
    echo "<h1>Database connection successful!</h1>";
} catch (PDOException $e) {
    echo "<h1>Database connection failed!</h1>";
    echo "<p>Error: " . $e->getMessage() . "</p>"; // THIS IS THE CRUCIAL ERROR MESSAGE YOU NEED TO SHARE
    echo "<p>Code: " . $e->getCode() . "</p>";
} catch (Throwable $e) {
    echo "<h1>An unexpected error occurred loading db.php or connecting!</h1>";
    echo "<p>Error: " . $e->getMessage() . "</p>";
    echo "<p>File: " . $e->getFile() . "</p>";
    echo "<p>Line: " . $e->getLine() . "</p>";
}
?>