我正在尝试连接到远程机架空间数据库 PHP:
<?php
$servername = "XX.XX.XX.XX";
$username = "username";
$password = "password";
$dbname = "table";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
我收到警告:mysqli :: mysqli():( HY000 / 2002):连接超时 任何建议
答案 0 :(得分:0)
试试这个
<?php
$servername = "XX.XX.XX.XX";
$username = "username";
$password = "password";
$dbname = "table";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();die();
}
?>