<?php

echo "<h2>PHP Database Connection Test</h2>";

$hosts = [
    "localhost",
    "127.0.0.1"
];

$user = "YOUR_DB_USER";
$pass = "YOUR_DB_PASSWORD";
$db   = "YOUR_DB_NAME";

foreach ($hosts as $host) {

    echo "<hr>";
    echo "Testing host: <b>$host</b><br>";

    $conn = @new mysqli($host, $user, $pass, $db);

    if ($conn->connect_error) {
        echo "FAILED: " . $conn->connect_error . "<br>";
    } else {
        echo "SUCCESS: Connected successfully!<br>";
        $conn->close();
    }
}
?>