我正在托管用于Geometry Dash的专用服务器。服务器本身工作正常。我正在尝试创建查询,但是当我运行查询时,该查询似乎“超时”。错误:
Connection Failure (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.
我尝试了一些简单的事情,例如禁用防火墙,使用IP作为主机而不是链接本身,似乎没有任何作用。
如果您有任何想法为什么不起作用,请告诉我。 (不要介意我的编码格式,这不是很好)
<html>
<head>
<style>
body {background-color: #ddd;}
</style>
</head>
</html>
<?php
$host = "sql.7m.pl";
$dbusername = "db-user21496";
$dbpassword = "(censored)";
$dbname = "db-user21496";
$username = filter_input(INPUT_POST, 'username');
$userCoins = filter_input(INPUT_POST, 'userCoins');
if (!empty($username)){
//Creates a connection:
$conn = new mysqli ($host, $dbusername, $dbpassword, $dbname);
// Error testing and reporting:
if(mysqli_connect_error()){
die('Connection Failure (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
} else {
// UPDATE/EDIT TABLE
$sql = "UPDATE users SET userCoins='$userCoins' WHERE username='$username'";
if ($conn->query($sql)){
echo "userCoins has been set to ".$userCoins.".";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
// CLOSE CONNECTION
$conn->close();
}
//EMPTY FIELD REPORTING
} else {
echo "Username should not be empty!";
die();
}
?>
该脚本应连接到服务器并从表用户更新变量userCoins。相反,它甚至没有连接,只是超时。