I tried to generate a .csv file, but I get this file empty. So my code is :
$fileName = 'Users_' . date('d-m-Y') . '.csv';
$fh = fopen($fileName, "w");
fputcsv($fh, array('EMAIL', 'NAME','SURNAME'), ";");
foreach ($aDataBases as $database) {
$sSql = sprintf('SELECT email, name, surname FROM users');
$rResult = Mysqli::query($sSql, $database);
while ($aRecord = $rResult->fetch_array(MYSQLI_ASSOC)){
fputcsv($fh, $aRecord['email'], ";");
fputcsv($fh, $aRecord['name'], ";");
fputcsv($fh, $aRecord['surname'], ";",'"');
}
}
fclose($fh);
The file is generate but is empty, can you help me please ? I make a print_r() and there are data after query execution. What I'm doing wrong ?