Foros del Web » Programando para Internet » PHP »

Warning: Cannot modify header information - headers already sent by (output started a

Estas en el tema de Warning: Cannot modify header information - headers already sent by (output started a en el foro de PHP en Foros del Web. que tal, tengo un error en mi pagina web, cuando la ejecuto local no tengo problemas, pero cuando la subo al servidor Cpanel, me da ...
  #1 (permalink)  
Antiguo 25/01/2010, 07:38
 
Fecha de Ingreso: enero-2010
Mensajes: 6
Antigüedad: 14 años, 3 meses
Puntos: 0
Warning: Cannot modify header information - headers already sent by (output started a

que tal, tengo un error en mi pagina web, cuando la ejecuto local no tengo problemas, pero cuando la subo al servidor Cpanel, me da el siguiente error:

Warning: Cannot modify header information - headers already sent by (output started at /home/futuro/public_html/archivosexcel.php:4) in /home/futuro/public_html/archivosexcel.php on line 87

Warning: Cannot modify header information - headers already sent by (output started at /home/futuro/public_html/archivosexcel.php:4) in /home/futuro/public_html/archivosexcel.php on line 88

Warning: Cannot modify header information - headers already sent by (output started at /home/futuro/public_html/archivosexcel.php:4) in /home/futuro/public_html/archivosexcel.php on line 89

Warning: Cannot modify header information - headers already sent by (output started at /home/futuro/public_html/archivosexcel.php:4) in /home/futuro/public_html/archivosexcel.php on line 90


estoy mandando los datos de la pagina a un excel, con el siguiente codigo:

<?php include "conexion.php";
$cod = $_GET['type'];
if($cod == 1){
echo '<table width="754" border="1">';
echo '<tr>';
echo '<td width="43">Folio</td>';
echo '<td width="120">Id Proyecto </td>';
echo '<td width="140">Titulo de Evento </td>';
echo '<td width="101">Detalle de Evento </td>';
echo '<td width="101">Fecha de Inicio </td>';
echo '<td width="101">Fecha de Termino </td>';
echo '<td width="102">Fecha de Creaci&oacute;n </td>';
echo '</tr>';
$listar = "SELECT * FROM bp_agendas";
$ejecutarlistar = mysql_query($listar,$con);
while($rs = mysql_fetch_array($ejecutarlistar,$seleccion_bd)){
echo'<tr>';
echo'<td>'. $rs['id_agenda'].'</td>';
echo'<td>'. $rs['idproy_agenda'].'</td>';
echo'<td>'. $rs['titulo_agenda'].'</td>';
echo'<td>'. $rs['detalle_agenda'].'</td>';
echo'<td>'. $rs['fechai_agenda'].'</td>';
echo'<td>'. $rs['fechat_agenda'].'</td>';
echo'<td>'. $rs['fechac_agenda'].'</td>';
echo'</tr>';
}
echo'</table>';

$file_type="vnd.ms-excel";
$file_name="Tabla_bp_agendas";
$file_ending="xls";

header("Content-type: application/$file_type");
header("Content-disposition: attachment; filename=$file_name.$file_ending");
header("Pragma: no-cache");
header("Expires: 0");
}
?>

Bueno, el codigo es mas extenso, pero se repite para 6 casos, por lo uqe se, es algo de que no puedo modificar las cabeceras o algo asi, porfavor ayuda.

Gracis
  #2 (permalink)  
Antiguo 25/01/2010, 07:40
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 11 meses
Puntos: 1517
Respuesta: Warning: Cannot modify header information - headers already sent by (outpu

No debes enviar información al navegador antes de usar los header, lee esto
http://www.forosdelweb.com/wiki/PHP:...lready_sent%3F
y tambien esto
http://www.forosdelweb.com/wiki/PHP:...n_line_4%22%3F
__________________
Verifica antes de preguntar.
Los verdaderos amigos se hieren con la verdad, para no perderlos con la mentira. - Eugenio Maria de Hostos
  #3 (permalink)  
Antiguo 25/01/2010, 08:50
 
Fecha de Ingreso: enero-2010
Mensajes: 6
Antigüedad: 14 años, 3 meses
Puntos: 0
Respuesta: Warning: Cannot modify header information - headers already sent by (outpu

Cita:
Iniciado por abimaelrc Ver Mensaje
No debes enviar información al navegador antes de usar los header, lee esto
[url]http://www.forosdelweb.com/wiki/PHP:%C2%BFPor_qu%C3%A9_si_guardo_mis_.php_con_codi ficaci%C3%B3n_UTF-8_me_aparece_un_error_del_tipo_Headers_already_sen t%3F[/url]
y tambien esto
[url]http://www.forosdelweb.com/wiki/PHP:%C2%BFPor_qu%C3%A9_me_sale_%22Warning:_Cannot_ modify_header_information_-_headers_already_sent_by_(output_started_at_1:2)_i n_3_on_line_4%22%3F[/url]
Los BOM no estan habilitados, no deveria ser eso... que podria ser?
  #4 (permalink)  
Antiguo 25/01/2010, 08:59
Avatar de dggluz  
Fecha de Ingreso: abril-2009
Ubicación: Buenos Aires, Argentina
Mensajes: 525
Antigüedad: 15 años
Puntos: 50
Respuesta: Warning: Cannot modify header information - headers already sent by (outpu

Las "cabeceras" se llaman así porque deben ir AL COMIENZO del documento (es decir que antes de los headers no debe imprimirse nada por pantalla) que le es enviado al browswer, así éste sabe cómo interpretarlo (si como una página web, como una imagen o cualquier otra cosa). En resumen: es una información que va "al comienzo" del documento y que le indica al browser cómo interpretar el resto. ¡Suerte!
  #5 (permalink)  
Antiguo 25/01/2010, 09:11
 
Fecha de Ingreso: enero-2010
Mensajes: 6
Antigüedad: 14 años, 3 meses
Puntos: 0
Respuesta: Warning: Cannot modify header information - headers already sent by (outpu

Solucionado, la verdad es que la respuesta estaba en frente de mi todo el tiempo, Dggluz me ilumino, con "Al Comienzo", tal como el dice, la especificacion de los headers va en la primera linea, y listo, saludos y gracias chicos

Etiquetas: header, modify, output, warning
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:19.