<?php
$servername = "localhost";
$username = "root";
$password = "";

// Connect to MySQL globally
$conn = new mysqli($servername, $username, $password);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Attempting SQL drop
$conn->query("DROP DATABASE IF EXISTS bm_business_db");
$conn->close();

// Attempting physical drop if SQL failed
$db_path = 'C:/xampp/mysql/data/bm_business_db';
if (is_dir($db_path)) {
    $files = new RecursiveIteratorIterator(
        new RecursiveDirectoryIterator($db_path, RecursiveDirectoryIterator::SKIP_DOTS),
        RecursiveIteratorIterator::CHILD_FIRST
    );

    foreach ($files as $fileinfo) {
        $todo = ($fileinfo->isDir() ? 'rmdir' : 'unlink');
        $todo($fileinfo->getRealPath());
    }
    rmdir($db_path);
    echo "Physical directory removed successfully.\n";
} else {
    echo "Directory not found or already removed.\n";
}
?>
