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

echo "<h1>Error Check</h1>";

// Test 1: PHP syntax
echo "<h2>Test 1: PHP Working</h2>";
echo "<p style='color: green;'>✓ PHP is working</p>";

// Test 2: Database connection
echo "<h2>Test 2: Database Connection</h2>";
try {
    require('include/dbconfig.php');
    echo "<p style='color: green;'>✓ Database config loaded</p>";
    
    if ($connection) {
        echo "<p style='color: green;'>✓ Database connected</p>";
    } else {
        echo "<p style='color: red;'>✗ Database connection failed</p>";
    }
} catch (Exception $e) {
    echo "<p style='color: red;'>✗ Error: " . $e->getMessage() . "</p>";
}

// Test 3: Check username column
echo "<h2>Test 3: Username Column</h2>";
$query = "SHOW COLUMNS FROM account LIKE 'username'";
$result = mysqli_query($connection, $query);
if ($result && mysqli_num_rows($result) > 0) {
    echo "<p style='color: green;'>✓ Username column exists</p>";
} else {
    echo "<p style='color: red;'>✗ Username column missing</p>";
}

// Test 4: Check user_access.php syntax
echo "<h2>Test 4: user_access.php Syntax</h2>";
$syntax_check = shell_exec('php -l user_access.php 2>&1');
if (strpos($syntax_check, 'No syntax errors') !== false) {
    echo "<p style='color: green;'>✓ No syntax errors</p>";
} else {
    echo "<p style='color: red;'>✗ Syntax error found:</p>";
    echo "<pre>" . htmlspecialchars($syntax_check) . "</pre>";
}

mysqli_close($connection);
?>
