Hi,
I've followed some code from previous threads.
However, I cannot get the following to work for me:
<?
$handle = fopen("emailcontacts.csv","w"); //local file
//$sqlQuesList = "Select contact_id,name,email,is_active,date_format(added_on,'%d-%m-%Y') as added_on from news_contact";
// $rsQuesList = mysql_query($sqlQuesList,$conn);
$sql = "select name,email from news_contacts";
print "yes";
$result = mysql_query($sql,$conn);
if ($result){
// $sql = "select * from ads";
//$result = mysql_query($sql,$conn);
$count = mysql_num_fields($result);
while ($rows = mysql_fetch_array($result)){
for ($i=0;$i<$count;$i++){
echo $rows[$i].","; //data
}
echo "\n"; //new line
}
}
fclose($handle);
//force download
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
header('Expires: 0');
header("Cache-control: private"); header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=emailcontacts.csv");
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: binary");
?>
And I get this error:
Warning: Cannot modify header information - headers already sent by (output started at /home2/btherapy/brieftherapy-www/admin/dumpmembers.php:31) in /home2/btherapy/brieftherapy-www/admin/dumpmembers.php on line 47