echo "Failed to connect to MySQL: " . mysqli_connect_error(); code example
Example: mysqli connect error
<?php
$conn=mysqli_connect("localhost","username","password","database_name");
?>
This code will connect with database 'database_name' while $conn is connection name