Headers sent woes : ob_start()??
Posted: Sat Sep 24, 2005 6:16 am
Hey Gang,
Am getting the following error :
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\collotype\materialsregister\template.inc:622) in c:\program files\easyphp1-8\www\collotype\includes\functions.inc.php on line 1415
and i haven't figured how to use ob_start() yet.
any ideas?
the code for the query works fine if I remove the headers.
I wish to make the browser compile and 'save' the csv contents to the desktop etc.
Am getting the following error :
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\collotype\materialsregister\template.inc:622) in c:\program files\easyphp1-8\www\collotype\includes\functions.inc.php on line 1415
and i haven't figured how to use ob_start() yet.
any ideas?
the code for the query works fine if I remove the headers.
I wish to make the browser compile and 'save' the csv contents to the desktop etc.
Code: Select all
function exportCSV () {
ob_start();
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=Materials-".date("d-m-Y").".csv");
header("Pragma: no-cache");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Expires: 0");
$query = ("SELECT *, aupapercategory.paperCategory FROM ausapapersummary
LEFT JOIN aupapercategory ON ausapapersummary.paperCategoryId = aupapercategory.papercategoryId
LEFT JOIN austock ON ausapapersummary.stockId = austock.StockId
LEFT JOIN auadhesive ON ausapapersummary.adhesiveId = auadhesive.adhesiveId
LEFT JOIN auliner ON ausapapersummary.linerId = auliner.linerId
LEFT JOIN ausupplier ON ausapapersummary.supplierId = ausupplier.supplierId
LEFT JOIN ausuitability ON ausapapersummary.suitabilityFoil = ausuitability.suitabilityId
LEFT JOIN admins ON ausapapersummary.ausapaperUserId = admins.id WHERE 1=1");
// Execute SQL Query
$result = mysql_query($query);
// Error SQL Query
if(!$result) error_message(sql_error());
// While loop for SQL output
while($query_data = mysql_fetch_array($result)) {
$summaryId = $query_data['summaryId'];
$paperCategoryId = $query_data['paperCategoryId'];
$colloPaperName = $query_data['colloPaperName'];
$manufacturerName = $query_data['manufacturerName'];
$cpl = $query_data['cpl'];
echo "$colloPaperName,", "$paperCategory,", "$manufacturerName,", "$supplier,", "$availability,", "$features,", "$limitations,", "$productExamples\n";
}
}