Foros del Web » Programando para Internet » PHP »

Problema: Cannot modify header information

Estas en el tema de Problema: Cannot modify header information en el foro de PHP en Foros del Web. Hola a todos, Ayer integré el login de phpBB a un sitio php que estoy diseñando. Logré hacer que este funcione a la perfección pero ...
  #1 (permalink)  
Antiguo 09/10/2010, 08:20
 
Fecha de Ingreso: agosto-2009
Mensajes: 349
Antigüedad: 14 años, 8 meses
Puntos: 8
Problema: Cannot modify header information

Hola a todos,

Ayer integré el login de phpBB a un sitio php que estoy diseñando. Logré hacer que este funcione a la perfección pero cuando ingresa al website alguien que no esta logeado se muestra el siguiente error:

Código:
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /home/audition/public_html/carpetaken/index.php:10)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /home/audition/public_html/carpetaken/index.php:10)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /home/audition/public_html/carpetaken/index.php:10)
session.php - Lineas 999 ~ 1008:

Código PHP:
    function set_cookie($name$cookiedata$cookietime)
    {
        global 
$config;

        
$name_data rawurlencode($config['cookie_name'] . '_' $name) . '=' rawurlencode($cookiedata);
        
$expire gmdate('D, d-M-Y H:i:s \\G\\M\\T'$cookietime);
        
$domain = (!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' '; domain=' $config['cookie_domain'];

        
header('Set-Cookie: ' $name_data . (($cookietime) ? '; expires=' $expire '') . '; path=' $config['cookie_path'] . $domain . ((!$config['cookie_secure']) ? '' '; secure') . '; HttpOnly'false);
    } 
index.php:

Código PHP:
Ver original
  1. <? include('variables.php');?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html40/loose.dtd">
  3. <html>
  4.   <head>
  5.   <title>AuditionTown - Fanáticos como tú!</title>
  6.     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  7.     <link href="estilos.css" rel="stylesheet" type="text/css">
  8.   </head>
  9.     <body bgcolor="#CD43A3">
  10.   <table width="100%" height="2" style="background:url('imagenes/fondo_at1.jpg');background-repeat:no-repeat;background-position:top center;" cellpadding="0" cellspacing="0" border="0">
  11.   <tr valign="top">
  12.   <td><div align="center"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0" id="logo_flotante" width="1000" height="350"><param name="movie" value="logo flotante.swf"><param name="wmode" value="transparent"><param name="quality" value="high"><param name="allowscriptaccess" value="samedomain"><embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" name="logo_flotante" width="1000" height="350" src="logo flotante.swf" quality="high" swliveconnect="true" allowscriptaccess="samedomain" wmode="transparent"></embed></object></div></td></tr>
  13.     <tr valign="top">
  14.     <td>
  15.         <div align="center" style="padding-left:1px;">
  16.         <table align="center" cellpadding="0" cellspacing="0" border="0" width="999" style="background: #5c004e url('imagenes/fondotop.png');background-repeat:repeat-x;">
  17.         <tr>
  18.         <td width="1" style="background: url('clear_right.jpg');background-repeat:repeat-y;"><img src="imagenes/clear_right.jpg"></td><td>
  19.     <!-- contenido -->
  20.     <br>
  21.     <div style="padding-left:15px;padding-right:15px;"><table align="center" width="700" height="150" cellpadding="0" cellspacing="0">
  22.     <tr valign="top">
  23.     <td width="20%">
  24. <? include('izquierda.php');?>
  25. </td>
  26. <td width="60%">
  27. <? include('centro.php');?>
  28.     </td><td width="20%">
  29. <? include('derecha.php')?>
  30.     </td></tr></table>
  31.     </div>
  32.     <!-- contenido -->
  33.     <br>
  34.     <br>
  35.     </td><td width="1" style="background: url('imagenes/clear_right.jpg');background-repeat:repeat-y;"><img src="imagenes/clear_right.jpg"></td>
  36.     </tr>
  37.     </table></div>
  38.     </td>
  39.     </tr>
  40.     <tr>
  41.     <td>
  42. <? include('footer.php');?>
  43.     </td></tr>
  44.     </table>
  45.   </body>
  46. </html>

La línea: include izquierda.php llama al menu izquierda:

Código PHP:
Ver original
  1. <!-- TABLA IZQUIERDA -->
  2.     <div style="padding-top:37px;padding-right:5px;">
  3.     <? echo $top_tabla?>MENU PRINCIPAL<? echo $tabla_2?>
  4. MENU PRINCIPAL OPCIONES
  5. <? echo $tabla_3?>
  6.     <? echo $top_tabla?>INGRESAR<? echo $tabla_2?><div align="center">
  7.     <? include('login.php');?></div>
  8. <? echo $tabla_3?></div>
  9.     <!-- TABLA IZQUIERDA -->

Y por último la línea include login.php llama al login:

Código PHP:
Ver original
  1. <?php
  2.     define('IN_PHPBB', true); // se define que se va a usar phpbb.
  3. $phpbb_root_path = '/home/audition/public_html/foro/'; // el path directo del servidor a phpbb3, varia algo dependiendo del servidor, si hay errores con esto en el mismo error sale el path correcto.
  4. $phpbb_url_path = 'http://auditiontown.net/foro/'; // la url hacia tu phpbb3
  5. $phpEx = substr(strrchr(__FILE__, '.'), 1); // tipo de extension
  6. include($phpbb_root_path . 'common2.' . $phpEx); // incluimos el common.php que es muy importante para la bd
  7.  
  8. $user->session_begin();
  9. $auth->acl($user->data);
  10.  
  11.     if($user->data['is_registered'])
  12.     {
  13.     $dbms = 'mysqli';
  14. $dbhost = 'localhost';
  15. $dbport = '';
  16. $dbname = '******';
  17. $dbuser = '******';
  18. $dbpasswd = '******';
  19. $conn = mysql_connect($dbhost,$dbuser,$dbpasswd) or die();
  20. $huboerror = mysql_select_db($dbname,$conn) or die();
  21.  
  22.     $avvy = "SELECT * FROM phpbb_users WHERE user_id =" . $user->data['user_id'];
  23.     $result = mysql_query($avvy,$conn) or die (mysql_error());
  24.  
  25.     while($row = mysql_fetch_array($result))
  26.     {
  27.     $link = $row['user_avatar'];
  28.     $width = $row['user_avatar_width'];
  29.     $height = $row['user_avatar_height'];
  30.     }?>
  31. LOGEADO
  32.  
  33. <?php
  34.     } else {
  35. ?>
  36. LOGEATE
  37. <?php }
  38. ?>


Sé que el problema podria ser que la session se esta ejecutando despúes de un código HTML, pero he intentado acomodarlo y no he tenido éxito alguno.

Espero que alguien pueda ayudarme,
Gracias.
  #2 (permalink)  
Antiguo 09/10/2010, 08:31
Avatar de ZydRick  
Fecha de Ingreso: febrero-2005
Ubicación: Lima
Mensajes: 750
Antigüedad: 19 años, 2 meses
Puntos: 4
Respuesta: Problema: Cannot modify header information

El problema está en que no puedes enviar NADA antes de modificar las cabeceras (con funciones como setcookie(), header() o session_start()). Posiblemente tengas un espacio antes o después de abrir/cerrar el modo de PHP, concretamente en el archivo index.php en la línea 10.

Etiquetas: header, modify
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 22:00.