query("SELECT VERSION() as version, DATABASE() as current_db, NOW() as server_time"); $result = $stmt->fetch(PDO::FETCH_ASSOC); echo " MySQL Version: {$result['version']}\n"; echo " Current Database: {$result['current_db']}\n"; echo " Server Time: {$result['server_time']}\n\n"; // Cek tabel yang ada echo "Mengecek tabel yang ada...\n"; $stmt = $db->query("SHOW TABLES"); $tables = $stmt->fetchAll(PDO::FETCH_COLUMN); if (empty($tables)) { echo " ⚠️ Tidak ada tabel di database ini\n"; } else { echo " ✅ Ditemukan " . count($tables) . " tabel:\n"; foreach ($tables as $table) { echo " - {$table}\n"; } } echo "\n=== Test Selesai ===\n"; } catch (\PDOException $e) { echo "❌ Error: Koneksi database GAGAL!\n"; echo " Pesan Error: " . $e->getMessage() . "\n"; echo "\nKemungkinan penyebab:\n"; echo " 1. Database server tidak berjalan\n"; echo " 2. Host/Port salah\n"; echo " 3. Username/Password salah\n"; echo " 4. Database tidak ada\n"; echo " 5. User tidak punya akses ke database\n"; exit(1); }