JezK
Edit File: setup_db.php
<?php define('DB_HOST', 'localhost'); define('DB_USER', 'root'); define('DB_PASS', ''); try { // Connect without DB name to create it $pdo = new PDO("mysql:host=" . DB_HOST, DB_USER, DB_PASS); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = file_get_contents('db.sql'); // We need to handle the Create Database separately if we want to use specific catch logic, // but the SQL file has IF NOT EXISTS, so executing it directly or chunk by chunk is okay. // However, PDO doesn't always like multiple queries in one go depending on driver config. // Let's execute the CREATE DATABASE first. $pdo->exec("CREATE DATABASE IF NOT EXISTS ppmet_platform"); $pdo->exec("USE ppmet_platform"); // Now split the SQL file by semicolons just to be safe, or try running it if driver supports it. // simpler to just put the table definitions in hardcoded strings here or read the file. // I will read the file and try to execute. If it fails, I'll split. // Actually, let's just use the SQL file content but with the password hash fixed for the admin. $adminPass = password_hash('admin123', PASSWORD_BCRYPT); $sqlContent = file_get_contents('db.sql'); // Replace the placeholder hash with real one $sqlContent = str_replace('$2y$10$abcdefghijklmnopqrstuv', $adminPass, $sqlContent); $pdo->exec($sqlContent); echo "Database setup completed successfully."; } catch (PDOException $e) { die("DB Setup Error: " . $e->getMessage()); } ?>