首先,我絕不是PHP的新手,或者發送頭文件。但是,我收到以下錯誤:什麼可能會導致標題已被髮送,我將如何跟蹤它?
Warning: Cannot modify header information - headers already sent in /var/www/oraviewer/download/scripts/start.inc on line 30
Warning: Cannot modify header information - headers already sent by (output started at /var/www/oraviewer/download/scripts/start.inc:30) in /var/www/oraviewer/download/scripts/start.inc on line 31
Warning: Cannot modify header information - headers already sent by (output started at /var/www/oraviewer/download/scripts/start.inc:30) in /var/www/oraviewer/download/scripts/start.inc on line 32
3錯誤,因爲我試圖發送3個標頭。
我搜遍了每一個文件,檢查它們是否有可能發送標題,換行符,文本等等,而且什麼都沒有。
我習慣了這種錯誤,告訴你打印的第一位來自哪裏(請參閱第二個錯誤以瞭解我的意思),但第一位不告訴我任何事情。
據我所知,自從我上次讓他們工作並使用備份副本後,這些文件都沒有發生任何變化,他們工作正常。不幸的是,如果我將它們替換爲備份文件,問題依然存在。我會發布這些文件,但其中大約有六打,達到了幾百行。
所以,我的主要問題:什麼可能導致這種情況,我將如何追蹤它來自哪裏?
編輯:3條線在30-32,whcih是特定的頭文件被打印
header('Content-Type: application/octet-stream');
header('Content="text/plain;charset=ISO-8859-1"');
header('Content-Disposition: attachment; filename="'.$fileName.'"');
如果我評論一出,誤差在下一之一啓動,所以我知道它的這些東西面前。
在getExtract.php文件start.inc之前的代碼:
<?php
include_once "start.inc";
的start.inc文件:
<?php
$extract = $_GET['extract'];
$debug = $_GET['debug'];
include "../../lib/conf.inc";
include $mainsitedir."/lib/db_connect.inc";
include $mainsitedir."/lib/utils.inc";
include "../queries/get_output_file_name.php";
$db_link = connect_db();
$query = "SELECT * FROM extract_wxo_list WHERE extract_id='{$_GET['extract']}'";
$file = db_get_row(db_query($db_link, $query));
$fileName = $file['OUTPUT_FILE_NAME'];
if (!empty($_GET['versiondate'])) {
$sql = "SELECT * FROM version_history WHERE version_start_date = '{$_GET['versiondate']}'";
$vquery = db_query($db_link, $sql);
if ($vrow = db_get_row($vquery)) {
$splitName = preg_split("/[.]/", $fileName, 2);
$fileName = $splitName[0].'_'.str_replace(".", "", $vrow['VERSION']).'.'.$splitName[1];
}
}
if ($_GET['debug']) {
echo "$fileName<br /><pre>";
} else {
header('Content-Type: application/octet-stream');
header('Content="text/plain;charset=ISO-8859-1"');
header('Content-Disposition: attachment; filename="'.$fileName.'"');
}
date_default_timezone_set('UTC');
?>
4包括靠近頂部是在其他幾個文件相同。他們也使用類似但不那麼通用的方式標題,所以我可以將它們排除在外。
你可能會在'/var/www/oraviewer/download/scripts/start.inc:30'上發帖嗎?3個錯誤都說輸出開始了嗎? – animuson
看起來像第30行的/var/www/oraviewer/download/scripts/start.inc。 –
嘗試在不同的地方使用obstart來做同樣的事情?當你刪除這3行時會發生什麼? –