fix koneksi database admin

This commit is contained in:
z0rayy
2026-06-10 22:24:32 +07:00
parent 1aaa20afa9
commit 4928f53982
4 changed files with 175 additions and 111 deletions
+12 -6
View File
@@ -39,20 +39,26 @@ try {
echo "=== CEK TABEL ===\n";
$tables = ['users', 'spbu', 'rumah_ibadah', 'penduduk_miskin'];
$tableExists = [];
foreach ($tables as $table) {
$result = $conn->query("SHOW TABLES LIKE '$table'");
$exists = $result->num_rows > 0;
$tableExists[$table] = $exists;
echo "Tabel '$table': " . ($exists ? "ADA" : "TIDAK ADA") . "\n";
}
echo "\n=== CEK USER ADMIN ===\n";
$result = $conn->query("SELECT username, created_at FROM users LIMIT 5");
if ($result && $result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "User: " . $row['username'] . " | Dibuat: " . $row['created_at'] . "\n";
}
if (!$tableExists['users']) {
echo "Tabel users belum ada. Jalankan: php scripts/init_db.php\n";
} else {
echo "Tabel users kosong - belum ada user!\n";
$result = $conn->query("SELECT username, created_at FROM users LIMIT 5");
if ($result && $result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "User: " . $row['username'] . " | Dibuat: " . $row['created_at'] . "\n";
}
} else {
echo "Tabel users kosong - belum ada user!\n";
}
}
} catch (mysqli_sql_exception $e) {