<?php
require_once 'config.php';

echo "Checking database connection...\n\n";

$conn = getDBConnection();
echo "✓ Database connection successful!\n\n";

// Check if events table exists
$result = $conn->query("SHOW TABLES LIKE 'events'");
if ($result && $result->num_rows > 0) {
    echo "✓ 'events' table exists!\n\n";
    
    // Show table structure
    echo "Table structure:\n";
    echo str_repeat("-", 50) . "\n";
    $result = $conn->query("DESCRIBE events");
    if ($result) {
        while ($row = $result->fetch_assoc()) {
            echo sprintf("%-20s %-20s %s\n", 
                $row['Field'], 
                $row['Type'], 
                $row['Null'] === 'YES' ? 'NULL' : 'NOT NULL'
            );
        }
    }
    
    // Count records
    $result = $conn->query("SELECT COUNT(*) as count FROM events");
    if ($result) {
        $row = $result->fetch_assoc();
        echo "\n✓ Total events in database: " . $row['count'] . "\n";
    }
} else {
    echo "✗ 'events' table not found!\n";
}

$conn->close();
echo "\n✓ Database setup is complete and working!\n";
?>

