Path : /home/vishqocm/pcib.in/admin/
File Upload :
Current File : //home/vishqocm/pcib.in/admin/debug.php

<?php
// Include database configuration
require_once '../admin/database/db_config.php';

// Enable error reporting
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

echo "<h1>Database Table Structure</h1>";

// Check courses table structure
echo "<h2>Courses Table Structure</h2>";
$result = $conn->query("SHOW COLUMNS FROM courses");
if ($result) {
    echo "<table border='1'><tr><th>Field</th><th>Type</th><th>Null</th><th>Key</th><th>Default</th><th>Extra</th></tr>";
    while ($row = $result->fetch_assoc()) {
        echo "<tr>";
        echo "<td>" . $row['Field'] . "</td>";
        echo "<td>" . $row['Type'] . "</td>";
        echo "<td>" . $row['Null'] . "</td>";
        echo "<td>" . $row['Key'] . "</td>";
        echo "<td>" . ($row['Default'] !== NULL ? $row['Default'] : "NULL") . "</td>";
        echo "<td>" . $row['Extra'] . "</td>";
        echo "</tr>";
    }
    echo "</table>";
} else {
    echo "Error fetching courses table structure: " . $conn->error;
}

// Check categories table structure
echo "<h2>Categories Table Structure</h2>";
$result = $conn->query("SHOW COLUMNS FROM categories");
if ($result) {
    echo "<table border='1'><tr><th>Field</th><th>Type</th><th>Null</th><th>Key</th><th>Default</th><th>Extra</th></tr>";
    while ($row = $result->fetch_assoc()) {
        echo "<tr>";
        echo "<td>" . $row['Field'] . "</td>";
        echo "<td>" . $row['Type'] . "</td>";
        echo "<td>" . $row['Null'] . "</td>";
        echo "<td>" . $row['Key'] . "</td>";
        echo "<td>" . ($row['Default'] !== NULL ? $row['Default'] : "NULL") . "</td>";
        echo "<td>" . $row['Extra'] . "</td>";
        echo "</tr>";
    }
    echo "</table>";
} else {
    echo "Error fetching categories table structure: " . $conn->error;
}

// Check the first few rows of the courses table
echo "<h2>Sample Courses Data</h2>";
$result = $conn->query("SELECT * FROM courses LIMIT 3");
if ($result) {
    if ($result->num_rows > 0) {
        $row = $result->fetch_assoc();
        echo "<table border='1'><tr>";
        foreach ($row as $key => $value) {
            echo "<th>" . $key . "</th>";
        }
        echo "</tr>";
        
        // Reset the pointer
        $result->data_seek(0);
        
        while ($row = $result->fetch_assoc()) {
            echo "<tr>";
            foreach ($row as $value) {
                echo "<td>" . (is_null($value) ? "NULL" : $value) . "</td>";
            }
            echo "</tr>";
        }
        echo "</table>";
    } else {
        echo "No data in courses table";
    }
} else {
    echo "Error fetching courses data: " . $conn->error;
}
?>