Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/07/2013, 13:48
SeFaS90
 
Fecha de Ingreso: mayo-2013
Mensajes: 27
Antigüedad: 11 años
Puntos: 1
Problemas con la exportacion desde php a txt

Cuando exporto los datos cuando son muchos comienza a fallar y se abre la ventana del navegador con los datos... lo cual no es lo q necesito,
necesito que se abra un archivo descargable
les dejo el codigo para ver si hay algo malo
Código PHP:
<?php
$downloadfile
="prueba.txt";

$sql="CONSULTA SQL";
$result=mysql_query($sql) or die(mysql_error());
while(
$row=mysql_fetch_array($result))
{
    
$i++;
    
$fe=explode("-",$row['fechav']);
    
$fec=$fe[2].".".$fe[1].".".$fe[0];
$filecontent=$row['1']."|".$row['2']."|".$row['3']."|".$row['4']."|".$fec."|".$row['6']."|".$row['7']."|".$row['8']."|".$row['9']."|".$row['10']."|A|0"."\r\n";
    if(
$filecontent==NULL || $filecontent==0)
    {
        
$filecontent="hola";echo $filecontent;}
    else{echo 
$filecontent;}
}
header("Content-disposition: attachment; filename=$downloadfile");
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".strlen($filecontent));
header("Pragma: no-cache");
header("Expires: 0");
?>