Foros del Web » Programando para Internet » PHP »

error en header

Estas en el tema de error en header en el foro de PHP en Foros del Web. Tengo el siguiente error: Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\con\common\funciones.php:20) in C:\AppServ\www\con\listado_cliente.php on line 37 Código: <?php ...
  #1 (permalink)  
Antiguo 22/07/2008, 17:32
 
Fecha de Ingreso: junio-2008
Mensajes: 110
Antigüedad: 15 años, 10 meses
Puntos: 0
error en header

Tengo el siguiente error:

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\con\common\funciones.php:20) in C:\AppServ\www\con\listado_cliente.php on line 37

Código:
<?php
include ("common/seguridad.php");
require("common/funciones.php");
head();
menu();
?>

    <div id="colRight">
    <h2>1.2. Listado de Clientes</h2>
      <div id="modulo">
    <table>
          <tr>
            <th>Empresa</th>
            <th>Dirección</th>
            <th>Localidad</th>
            <th>CP</th>
            <th>Tel.</th>
            <th>Fax</th>
            <th>Contacto</th>
            <th>E-mail</th>
            <th>Cargo</th>
            <th>&nbsp;</th>
            <th>&nbsp;</th>
          </tr>
          <?php
			$conn = mysql_connect('localhost','contadores','admin');
			mysql_select_db('contadores',$conn);  		  
		 		 	
		 	
		 	if(isset($_GET['delete'])) {
				$sql = 'DELETE FROM `cliente` WHERE `cliente`.`id_cliente` ='.$_GET['delete'] . ' LIMIT 1';
				$rs = mysql_query($sql,$conn);
				
			} 
			
			if(isset($_GET['modify'])) {
				header("Location: nuevo_cliente.php");
			}
			
				$sql = 'SELECT * FROM `cliente` WHERE 1 LIMIT 0, 30 '; 	
				$rs = mysql_query($sql,$conn);		 	
			
				$cant = mysql_num_rows($rs);		

				while($row = mysql_fetch_array($rs)) {
					echo "<tr>";
		            echo "<td>" .$row['empresa']. "</td>";    
		            echo "<td>" .$row['direccion']. "</td>";
		            echo "<td>" .$row['localidad']. "</td>";
		            echo "<td>" .$row['cp']. "</td>";
		            echo "<td>" .$row['telefono']. "</td>";
		            echo "<td>" .$row['fax']. "</td>";
		            echo "<td>" .$row['contacto']. "</td>";
		            echo "<td><a href=\"mailto:".$row['email']."\">" .$row['email']. "</a></td>";
		            echo "<td>" .$row['cargo']. "</td>";
		            echo "<td><a href=\"listado_cliente.php?modify=". $row['id_cliente'] ."\"><img src=\"http://www.forosdelweb.com/images/icons/modify.gif\" alt=\"Modificar\" /></a></td>";
		            echo "<td><a href=\"listado_cliente.php?delete=". $row['id_cliente'] ."\"><img src=\"http://www.forosdelweb.com/images/icons/delete.gif\" alt=\"Delete\" /></a></td>";
		          	echo "</tr>";		

				}
	          
			mysql_close($conn);	
			?>
        </table>
      </div>
    
<?php
	footer();
?>
Esta es la parte que agregue que me genera el error:

Código:
			if(isset($_GET['modify'])) {
				header("Location: nuevo_cliente.php");
			}
Lo que necesito es redireccionar a otra pagina, como puedo hacerlo?
  #2 (permalink)  
Antiguo 22/07/2008, 17:37
 
Fecha de Ingreso: septiembre-2004
Mensajes: 324
Antigüedad: 19 años, 7 meses
Puntos: 13
Respuesta: error en header

Hola

el mismo error te está diciendo la solucion:
...headers already sent by...


las cabeceras ya se han enviado y no las puedes enviar de nuevo.

Saludos
  #3 (permalink)  
Antiguo 22/07/2008, 17:38
 
Fecha de Ingreso: julio-2008
Ubicación: El Puerto de Santa María
Mensajes: 62
Antigüedad: 15 años, 9 meses
Puntos: 0
Respuesta: error en header

La función header() debe usarse al principio del código.
Para redirigir puedes usar lo siguiente:
Código PHP:
if(isset($_GET['modify'])) {
                echo 
"<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=nuevo_cliente.php\">";
            } 
Saludos
  #4 (permalink)  
Antiguo 22/07/2008, 18:07
 
Fecha de Ingreso: junio-2008
Mensajes: 110
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: error en header

Cita:
Iniciado por Kwic Ver Mensaje
La función header() debe usarse al principio del código.
Para redirigir puedes usar lo siguiente:
Código PHP:
if(isset($_GET['modify'])) {
                echo 
"<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=nuevo_cliente.php\">";
            } 
Saludos
Muchas Gracias, lo pude solucionar de la forma que mencionas.
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:35.