版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/vernice/article/details/68938836
After registering my domain on Hostinger, I tried to connect the Hostinger MySQL database from PHP script. Be careful about the server name:
<?php
$servername = "localhost"; // work
$servername = "mysql.hostinger.com"; // not work
$servername = "182.12.24.1"; // not work
$username = "uxxxx_xxx";
$password = "xxxxxx";
$dbname = "uxxxx_xxx";
// create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
?>