What are the potential pitfalls of using mysqli_connect in PHP, especially with XAMPP installations?

When using mysqli_connect in PHP with XAMPP installations, one potential pitfall is not specifying the correct hostname, username, password, and database name which can lead to connection errors. To solve this issue, ensure that you provide the correct credentials in the mysqli_connect function call.

// Correctly specify the hostname, username, password, and database name in the mysqli_connect function
$host = "localhost";
$username = "root";
$password = "";
$database = "my_database";

$conn = mysqli_connect($host, $username, $password, $database);

// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";