【问题标题】:Prevent timeout using flush but page not redirecting after flush防止使用刷新超时但刷新后页面不重定向
【发布时间】:2015-02-21 01:25:48
【问题描述】:

我正在使用刷新防止超时。我尝试了其他方法,但负载均衡器设置对我来说是锁定的。

我的脚本完全处理大量记录。

if (mysqli_num_rows($stream) > 0) {

while($row = mysqli_fetch_assoc($stream)) {
 //updating user's ticket information 
     $unique = $row[ticketid];
     $result = $pk->updateticket($unique, $data);

//flushing to keep connection alive
flush();
ob_flush();
}
 } 

 header('Location: tickets.php');  //the redirect isn't executed - page becomes blank. Records are processed though.

但是,我在处理后重定向用户。这个标题位置没有被执行,页面只是变成空白。

【问题讨论】:

    标签: php timeout flush


    【解决方案1】:

    在刷新任何内容后您不能使用 header(),因为标头已经发送 (http://php.net/manual/en/function.header.php)

    你可以改用

    echo '<script type="text/javascript">
    location.replace("tickets.php");
    </script>';
    

    甚至

    echo '<META http-equiv="refresh" content="1;URL=tickets.php">';
    

    【讨论】:

      猜你喜欢
      • 2016-01-18
      • 1970-01-01
      • 2020-12-31
      • 2021-11-19
      • 2017-03-14
      • 2011-12-14
      • 1970-01-01
      • 2018-07-04
      • 1970-01-01
      相关资源
      最近更新 更多