PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Can any folk see why the following might not work?
It's spitting :
Warning: Cannot modify header information - headers already sent by (output started at \www\collotype\materialsregister\template.inc:622) in \www\collotype\includes\functions.inc.php on line 140 (Which is the first Header Line).
function exportSAData () {
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=SMSRealty-Sales-Leads-".date("Y-m-d").".csv");
header("Pragma: no-cache");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Expires: 0");
// You do not need to change the function
$query = mysql_query("SELECT ausapapersummary.summaryId, aupapercategory.paperCategory, ausapapersummary.colloPaperName, ausapapersummary.manufacturerName, ausapapersummary.cpl, austock.stockDescription, auadhesive.adhesiveDescription, auliner.linerDescription, ausupplier.supplier 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 WHERE 1=1");
$row = mysql_fetch_array($query);
print "$header\n$row";
}
my guess is that this is already coming after something has been printed to the browser. also print $header will not work because $header is not a variable. You're setting the header for the php page to send to the browser, not making it a variable
if you wanted to see what the header would be you could do
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
check the page that calls the function and look for any output before the call, even white space can cause problems sometimes. The headers should be the first output on the page, so before this function is called no output but you can have php code. n00b is right echoing $header wouldn't do much.
phpdevuk wrote: n00b is right echoing $header wouldn't do much.
he means scrotaye ;d
(sorry n00b) =)
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.