<?php
// Test different password combinations
error_reporting(E_ALL);
ini_set('display_errors', 1);

echo "<h2>Testing MySQL Passwords</h2>";

$passwords = ['', 'root', 'admin', 'password', '123456'];
$host = 'localhost';
$user = 'root';
$db = 'bidda';

foreach ($passwords as $pass) {
    try {
        $pdo = new PDO("mysql:host=$host;charset=utf8mb4", $user, $pass, [
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_TIMEOUT => 3
        ]);
        echo "<p style='color: green;'><strong>✓ Success! Password is: '" . ($pass ?: '(empty)') . "'</strong></p>";
        
        // Try to create database
        try {
            $pdo->exec("CREATE DATABASE IF NOT EXISTS $db");
            echo "<p style='color: green;'>✓ Database '$db' created or exists</p>";
        } catch(Exception $e) {
            echo "<p style='color: orange;'>⚠ Database error: " . $e->getMessage() . "</p>";
        }
        break;
    } catch(PDOException $e) {
        echo "<p style='color: red;'>✗ Failed with password '" . ($pass ?: '(empty)') . "': " . substr($e->getMessage(), 0, 50) . "...</p>";
    }
}

echo "<hr>";
echo "<p><strong>Solution:</strong></p>";
echo "<p>Update your .env file with the correct password:</p>";
echo "<code>DB_PASS=your_password_here</code>";
