<?php
$servername = "localhost";
$username = "livepuwk_rahul";
$password = "Dada@2050";
$database = "livepuwk_rahul";

echo "<h3>Database Connection Test</h3>";

$conn = mysqli_connect($servername, $username, $password);

if (!$conn) {
    echo "<p style='color:red;'><b>STEP 1 FAILED:</b> Could not connect to MySQL server. Error: " . mysqli_connect_error() . "</p>";
    echo "<p>Tip: Check if the username and password are correct.</p>";
} else {
    echo "<p style='color:green;'><b>STEP 1 SUCCESS:</b> Connected to MySQL server successfully.</p>";
    
    $db_selected = mysqli_select_db($conn, $database);
    if (!$db_selected) {
        echo "<p style='color:red;'><b>STEP 2 FAILED:</b> Could not select database '$database'. Error: " . mysqli_error($conn) . "</p>";
        echo "<p>Tip: Check if the database name is correct and the user has permissions.</p>";
    } else {
        echo "<p style='color:green;'><b>STEP 2 SUCCESS:</b> Selected database '$database' successfully.</p>";
        echo "<p>Your connection settings are correct!</p>";
    }
}
?>
