我正在尝试测试我在ftp中的工作与db4free.net中的数据库之间的连接,但我总是得到一个超时错误
Fatal error: Uncaught exception 'PDOException'
with message 'SQLSTATE[HY000] [2002] Connection timed out'
这是我的test.php
<?php
$user = "user***";
$pass = "***";
$host = "www.db4free.net";
$dbname = data123z;
$conn = new PDO("mysql:host={$host};dbname={$dbname}", $user, $pass);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT nom FROM aa";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "id: " . $row["nom"];
}
} else {
echo "0 results";
}
$conn->close();
?>
我甚至尝试插入端口3306和IP地址85.10.205.173,但它都是一样的。