Reputation: 1
Warning: mysqli::__construct(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
try{
$mysqli = new mysqli('cpanelhost','cpanel_db_user','cpanel_db_password','cpanel_db','port');
if ($mysqli -> connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli ->connect_error;
exit();
}
$sql = "INSERT INTO table (column1, column2) VALUES ('value1', 'value2')";
$mysqli->query($sql) ;
$mysqli->close();
}
catch(Exception $e){
$mysqli->close();
return $e;
}
Upvotes: 0
Views: 1063
Reputation:
I would highly recommend you to:
If the above is covered, then you will need to:
And if you still cannot establish a successful connection, I would recommend switching to a managed hosting provider which fully supports remote MySQL connections.
Upvotes: 1