可能重複:
「Warning: Cannot modify header information - headers already sent by」 error不能修改標題信息 - 頭已經發出[PHP,MySQL和CSV]
即時得到我的網站上
警告這些錯誤:無法修改標頭信息 - 已在/ home/****/public_html/monday/tuffturf/createrep中發送的標頭(輸出開始於/home/****/public_html/monday/tuffturf/createrep.php:7)。第103行的php
警告:無法修改頭信息 - 已在/ home/****/public_html /中發送的頭文件(輸出開始於/home/****/public_html/monday/tuffturf/createrep.php:7)/第104行的星期一/ tuffturf/createrep.php
警告:無法修改標題信息 - 標題信息已經發送(輸出開始於/home/****/public_html/monday/tuffturf/createrep.php:7)in /home/****/public_html/monday/tuffturf/createrep.php on line 105
警告:無法修改標題信息 - 標題已經發送(輸出開始於/ home/****/public_html /星期一/tuffturf/createrep.php:7)在/home/****/public_html/monday/tuffturf/createrep.php在線106 查詢失敗,請再試一次
mysql_fetch_assoc():提供的參數不是在
一個有效的MySQL結果資源我已經在PHP標籤檢查空格,我嘗試不同的東西,我不能找到解決
php的開始於線86,並使用下拉框選擇多少報告,以顯示在一個CSV報告,在134
<?php
$server = 'localhost';
$username = '*****';
$password = '*****';
mysql_connect($server, $username, $password);
mysql_select_db('***_turfdb')
or die ("unable to connect to mysql");
$reports = array(
'all' => 'SELECT * FROM quotepage',
'recent' => 'SELECT * FROM quotepage ORDER BY entered DESC LIMIT 20',
'oldest' => 'SELECT * FROM quotepage ORDER BY entered ASC LIMIT 20'
);
if (!array_key_exists($_POST['report'], $reports) || !isset($_POST))
{
die('Error generating report. please try again later.');
};
header("content-type:text/csv; charset=utf-8");
header('Content-Disposition:attachment;filename='.date('Y-m-d').'.csv');
header("pragma: no-cache");
header ("expires: 0");
/*if(isset($_POST) && !empty($_POST)) {
if(mysql_query($query)) {
echo "<script type=\"text/javascript\"> alert('All information entered was successfully will now show report.'); </script>";
} else {
echo "<script type=\"text/javascript\"> alert('There was an error please try again later.'); </script>";
echo mysql_error();
}
}*/
if(isset($_POST['header']))
{
$field = mysql_query('SHOW COLUMS FROM quotepage');
$label = array();
while($field = mysql_fetch_assoc($field));
{
$labels[] = $field ['Field'];
};
echo implode (',', $labels) . "\n";
}
$data = mysql_query($reports[$_POST['report']]);
while($row = mysql_fetch_assoc($data));
die ("query failed please try again");
{
echo implode(',', $row) . "\n";
}
?>
此結束
這是我第一次嘗試創建一個CSV報告,因此如果需要了解更多信息請諮詢
查看右邊的「相關」部分。 –