php 脚本因 broken pipe 错误而中止
你曾遇到过类似于“mysqli_query(): send of 309 bytes failed with errno=32 broken pipe”这样的错误吗?这个问题令人烦恼,并且会中断你的脚本。
为什么会发生 broken pipe 错误?
broken pipe 错误通常是因为 php 脚本与 mysql 服务器之间的连接由于长时间未操作而被关闭。当脚本再次尝试通过已关闭的连接执行查询时,就会导致错误。
立即学习“PHP免费学习笔记(深入)”;
如何修复 broken pipe 错误?
要解决 broken pipe 错误,你可以尝试以下方法:
set global wait_timeout = 1000;
if (!mysqli_ping($conn)) { // 断开连接 mysqli_close($conn); // 重新连接 $conn = mysqli_connect($host, $user, $password, $database); }
以上就是PHP 脚本因 Broken Pipe 错误而中止:如何解决“mysqli_query(): send of 309 bytes failed with errno=32 Broken pipe”?的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号