2010-08-02 65 views
-4

我的代码 - 发送不能更改头信息 - 头已经被错误

if ($result) 
{ 
    $row = $result->fetch_object(); 
    $filename = $row->src; 

    $q = "delete from photos WHERE id=$fileid"; 
    $result = $mysqli->query($q) or die(mysqli_error($mysqli)); 
    if ($result) 
    { 
     $filepath = "./images/"; 
     if(fileDelete($filepath,$filename)) 
     { 
      echo "success"; 
      header("Location: index.php"); 
      exit; 
     } 
     else echo "failed"; 
    } 
} 

输出 -

 
success 
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\pics\deletepic.php:31) in C:\xampp\htdocs\pics\deletepic.php on line 32 
+2

可能的重复:http://stackoverflow.com/questions/1827314/cannot-modify-header-information-headers-already-sent-why-its-happening http://stackoverflow.com/questions/3109141/cannot -modify-header-information-headers-already-sent-by http://stackoverflow.com/questions/1912029/warning-cannot-modify-header-information-headers-already-sent-by-error还有更多。 – 2010-08-02 11:04:29

+2

只是摆脱无用的'回声“成功”;'和'回声“失败”;' – 2010-08-02 11:08:06

+3

-1在谷歌键入您的确切标题给出+/- 43mio结果... – 2010-08-02 11:08:12

回答

5

不能呼应发送消息头的事情之前。

0

你不能送什么东西给客户,然后欢送头,设置Cookie和类似的东西。它不起作用,因为在HTTP中首先发送标题,并且当您开始响应正文时,您不能返回并重写标题。

相关问题