View Full Version : Headers sent woes : ob_start()??

09-24-2005, 12:16 PM
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.

function exportCSV () {


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";


09-24-2005, 01:53 PM
Sounds as if some sort of headers are being sent before you use ob_start(). Try moving it to the very top of your script and see if it changes anything.

09-24-2005, 02:10 PM
i have similar problem: i have the headers at the very beginning of the script, but warning is shown that i started sending data at line 1 (ONE, yes!)

code (copy-pasted):


//header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: no-store, no-cache, must-revalidate',true);
header('Connection: Keep-Alive',true);
header('stupid: yes');

code going on...

if i call ob_start() at the begiinning, does not help:(

09-24-2005, 02:25 PM
chances are you have a space or some kind of code before the opening <?php tag.

You chould call ob_start() at the VERY TOP of the page, before anything else, before you even type a space.. Then at the very bottom of the page you can use ob_end_flush(); to flush (send) the entire contents of the buffer.

09-26-2005, 07:06 AM
nono, my script STARTS with that code i wrote, so the first characters in the script are supposed to be '<?php'

i made this file with dw mx.. could be any problems with encoding?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum