cannot modify header information - headers already sent by [php, mysql, csv] -
possible duplicate:
“warning: cannot modify header information - headers sent by” error
im getting these errors on website
warning: cannot modify header information - headers sent (output started @ /home/****/public_html/monday/tuffturf/createrep.php:7) in /home/****/public_html/monday/tuffturf/createrep.php on line 103
warning: cannot modify header information - headers sent (output started @ /home/****/public_html/monday/tuffturf/createrep.php:7) in /home/****/public_html/monday/tuffturf/createrep.php on line 104
warning: cannot modify header information - headers sent (output started @ /home/****/public_html/monday/tuffturf/createrep.php:7) in /home/****/public_html/monday/tuffturf/createrep.php on line 105
warning: cannot modify header information - headers sent (output started @ /home/****/public_html/monday/tuffturf/createrep.php:7) in /home/****/public_html/monday/tuffturf/createrep.php on line 106 query failed please try again
mysql_fetch_assoc(): supplied argument not valid mysql result resource in
i have checked white spaces @ php tags, tried different things , cant find solution
the php starts @ line 86 , ends @ 134
<?php $server = 'localhost'; $username = '*****'; $password = '*****'; mysql_connect($server, $username, $password); mysql_select_db('***_turfdb') or die ("unable connect mysql"); $reports = array( 'all' => 'select * quotepage', 'recent' => 'select * quotepage order entered desc limit 20', 'oldest' => 'select * quotepage order 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 show report.'); </script>"; } else { echo "<script type=\"text/javascript\"> alert('there error please try again later.'); </script>"; echo mysql_error(); } }*/ if(isset($_post['header'])) { $field = mysql_query('show colums 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"; } ?>
this using drop down box select how many reports show on csv report
this first time have tried create csv report if more information needed please ask
as indicated error message, have output on line 7 of createrep.php.
header()
must used before any output sent browser (whitespace, html, etc).
you noted code provided on line 86. imagine you've output in 85 lines above.
Comments
Post a Comment