I am using the follow code to export CSV data for a customer:
function Push_File($Filename, $QUERY) {
$NUM_FIELDS = mysql_num_fields($QUERY);
header("Pragma: cache");
header("Content-Type: text/plain");
header("Content-Disposition: attachment; filename=".urlencode($Filename).".csv");
while ($Data = mysql_fetch_array($QUERY, MYSQL_NUM)) {
unset($CSV_Data);
$CSV_Data = '';
for ($I=0; $I < $NUM_FIELDS; $I++) {
$CSV_Data .= "\"$Data[$I]\",";
}
$CSV_Data = substr($CSV_Data,0,-1);
echo $CSV_Data."\r\n";
}
}
if ($_GET['Action'] == 'Survey_Data') {
$QUERY = mysql_query("SELECT * FROM mover_info");
$Filename = "SurveyData";
Push_File($Filename, $QUERY);
}
The problem is the file NEVER finishes. It stops at a different point every time. I have "max_execution_time" set to 0, but the download doesn't even continue for more than 15 seconds.
If anyone knows why this would be occuring, please let me know.
Thanks,
Tom 🙂