xxxxxxxxxx
If MySQL Server is up and running - then this looks like some transport (e.g. firewall) problem. First step is to try telnet command below - if it shows an error, then problem is not related to PHP or MySQL :
telnet 66.96.147.118 3306
(On success it will print mysql version + some random characters)
xxxxxxxxxx
<?php
$host = 'localhost'; // replace with actual host name
$user = 'username'; // replace with actual username
$pass = 'password'; // replace with actual password
$db = 'database'; // replace with actual database name
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>