我的 PHP 代码因以下错误而超时:
This request takes too long to process, it is timed out by the server. If it should not be timed out, please contact administrator of this web site to increase 'Connection Timeout'
我不确定为什么会这样。这是我的代码:
if(!in_array($name,$names)){
mysql_query("INSERT INTO `tbl` (`name`, `time`, `link`) VALUES ( '$name', '$time', '$link');");
} else {
mysql_query("UPDATE `tbl` SET `time` = '$time', `link` = '$link' WHERE `pishkhan`.`name` = $name;");
echo $name.'<br/>';
}
file_put_contents('test/albums/news/'.$name.".jpg", fopen($link, 'r'));
最佳答案
正如我在 my answer here 中所述,此特定错误消息是由 LiteSpeed Web 服务器(Apache 的更快替代品)生成的。它有一个特殊功能,可以取消长时间运行的脚本(即使是那些使用 set_time_limit()
的脚本)。要禁用此功能,您需要将以下内容放入站点根目录下的 .htaccess
文件中。
RewriteEngine On
RewriteRule .* - [E=noabort:1]
RewriteRule .* - [E=noconntimeout:1]
关于php - 如何在php中为请求超时计时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29623302/