I have a PHP code that does a query in the database and was to return the values to a CSV file, but this is not happening. The script is even returning the query, but the values are only in the browser and the CSV file is not created. I'm using serialize, would this be the problem?
<?php
$DB = new ConexaoBD();
$DB->ligarBD($NOME_BD, $USER_DB, $PASS_DB, $NOME_SERVIDOR);
$row = $DB->executarSQL($query);
$DB->fecharBD();
//echo "<pre>";print_r($row);echo "</pre>";
//ob_implicit_flush();
header('Content-Encoding: ISO-8859-1');
header('Content-Type: application/csv; charset=ISO-8859-1');
header("Content-Type: text/csv");
header('Content-Disposition: attachment; filename=Extracao_SkinAge.csv;');
//header("Content-Type: application/force-download");
//header( 'Pragma: no-cache');
$f = fopen('php://output', 'w');
//fputs($f, "teste arquivo");
//fputs($f, "\n");
$comma_separated = implode(";", $array_nomes);
fputs($f, $comma_separated);
fputs($f, "\n");
foreach ($row as $line) {
fputcsv($f, $line, ";");
}
fclose($f);
exit();
}
?>