2010-08-02 26 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中首先發送標題,並且當您開始響應正文時,您不能返回並重寫標題。

相關問題