gpt4 book ai didi

php - 让用户等待再次尝试连接 - mysqli php

转载 作者:行者123 更新时间:2023-11-28 23:27:44 25 4
gpt4 key购买 nike

我有这个连接到 mysqli:

$mysqli_c = new mysqli($host, $us, $password, $bd);

if (mysqli_connect_errno()) {
if (mysqli_errno() == 1203) {
header("Location: too_many.php");
exit;
}
}

这会出现“太多连接”错误。

我想要的不是重定向到 too_many.php,如果发生错误 1203,我想在 10 秒后重试。这样用户可以认为我的网站加载缓慢,但他不会看到错误页面。

知道怎么做吗?可以吗?

最佳答案

do {
$status="ok";
$sql = new mysqli("localhost", "root", "", "site");
if (mysqli_connect_errno()) {
$status = 'error';
sleep(10);
}
}while($status == 'error');

关于php - 让用户等待再次尝试连接 - mysqli php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38553614/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com