Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/02/2009, 07:41
fenixdemetal
 
Fecha de Ingreso: julio-2008
Ubicación: very high
Mensajes: 41
Antigüedad: 15 años, 9 meses
Puntos: 0
Headers! Fastidiosos Headers!

Hola a todos!, espero que una vez mas puedan echarme una mano,
resulta que estoy teniendo un problemita con php siempre, SIEMPRE que envio headers, tengo por ejemplo el siguiente codigo con el que se supone podria generar un archivo en excell.

Código:
<?php require_once('Connections/Myconection.php'); ?>
<?php session_start(); ?>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>
<body>
<?php mysql_select_db($database_Myconection, $Myconection);
$sql = "SELECT clientes.nombre,  preguntas.indicador, preguntas.tipo, preguntas.ask, puntaje.observaciones, puntaje.suma, puntaje.puntos
FROM clientes, preguntas, puntaje
WHERE puntaje.cliente=clientes.nit AND puntaje.pregunta=preguntas.id_pr  AND preguntas.iden=19";
$r =  mysql_query($sql) or trigger_error(mysql_error($Myconection),E_USER_ERROR); 
$return = '';
if( mysql_num_rows($r)>0){
    $return .= '<table border=1>';
    $cols = 0;
    while($rs = mysql_fetch_row($r)){
        $return .= '<tr>';
        if($cols==0){
            $cols = sizeof($rs);
            $cols_names = array();
            for($i=0; $i<$cols; $i++){
                $col_name = mysql_field_name($r,$i);
                $return .= '<th>'.htmlspecialchars($col_name).'</th>';
                $cols_names[$i] = $col_name;
            }
            $return .= '</tr><tr>';
        }
        for($i=0; $i<$cols; $i++){
            if($cols_names[$i] == 'fechaAlta'){ #Fromateo el registro en formato Timestamp
                $return .= '<td>'.htmlspecialchars(date('d/m/Y H:i:s',$rs[$i])).'</td>';
            }else if($cols_names[$i] == 'activo'){ #Estado lógico del registro, en vez de 1 o 0 le muestro Si o No.
                $return .= '<td>'.htmlspecialchars( $rs[$i]==1? 'SI':'NO' ).'</td>';
            }else{
                $return .= '<td>'.htmlspecialchars($rs[$i]).'</td>';
            }
        }
        $return .= '</tr>';
    }
    $return .= '</table>';
    mysql_free_result($r);
}
header("Content-type: application/vnd-ms-excel; charset=iso-8859-1");
header("Content-Disposition: attachment; filename=NombreDelExcel_".date('d-m-Y').".xls");
echo $return;?>
</body>
</html>
y me genera los siguientes errores:

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\Esatic\prueba.php:10) in C:\AppServ\www\Esatic\prueba.php on line 45

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\Esatic\prueba.php:10) in C:\AppServ\www\Esatic\prueba.php on line 46

Ya he visto en otros post y en otros foros, y dicen que pueden ser espacios en blanco pero aca no los tengo y las directivas de errores en php las tengo todas en off, y tampoco imprimo nada en pantalla antes de enviar los headers entonces que podria ser ??? alguna idea espero que puedan ayudarme que ya estoy bastante fastidiado con estos headers. Muchas Gracias por su tiempo.