Foros del Web » Creando para Internet » Herramientas y Software »

error: headers already sent

Estas en el tema de error: headers already sent en el foro de Herramientas y Software en Foros del Web. Hola foreros, he creado un formulario para introducir registros en una tabla utilizando dreamweaver 8 y sus asistente. El problema es que cuando el registro ...
  #1 (permalink)  
Antiguo 03/11/2008, 16:42
 
Fecha de Ingreso: octubre-2008
Mensajes: 53
Antigüedad: 15 años, 6 meses
Puntos: 0
error: headers already sent

Hola foreros,
he creado un formulario para introducir registros en una tabla utilizando dreamweaver 8 y sus asistente. El problema es que cuando el registro se introduce correctamente te redirecciona a una página donde te dice "Introducido correctamente", pero en lugar de redireccionarme me sale el dichoso error "headers already sent".
Ya probé con quitar los espacios, comprobar que no haya ningun echo o print, lo cargué en el bloc de notas...pero nada..sigue igual.
No puedo maaaaaaasssss.
Una ayudita.Gracias.
  #2 (permalink)  
Antiguo 03/11/2008, 16:55
Avatar de juaniquillo
Colaborador
 
Fecha de Ingreso: noviembre-2005
Ubicación: San Juan, Puerto Rico
Mensajes: 5.745
Antigüedad: 18 años, 5 meses
Puntos: 281
Respuesta: error: headers already sent

No hay otra explicación. Estas enviando los headers antes de hacer la re-dirección. Pon el código de la página donde haces el re-direct para poder analizarla.
__________________
Por fin.. tengo algo parecido a un blog
Y por lo visto ya estoy escribiendo...
  #3 (permalink)  
Antiguo 03/11/2008, 16:58
 
Fecha de Ingreso: octubre-2008
Mensajes: 53
Antigüedad: 15 años, 6 meses
Puntos: 0
Respuesta: error: headers already sent

Gracias por contestar, este es el código que genera el dreamweaver sin manipulación por mi parte:
<?php virtual('/sitiophp/Connections/conexcurso.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO alumnos (codigo, nombre, apellidos, nif) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['codigo'], "text"),
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['apellidos'], "text"),
GetSQLValueString($_POST['nif'], "text"));

mysql_select_db($database_conexcurso, $conexcurso);
$Result1 = mysql_query($insertSQL, $conexcurso) or die(mysql_error());

$insertGoTo = "/sitiophp/insertOK.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_conexcurso, $conexcurso);
$query_rsalumnos = "SELECT * FROM alumnos";
$rsalumnos = mysql_query($query_rsalumnos, $conexcurso) or die(mysql_error());
$row_rsalumnos = mysql_fetch_assoc($rsalumnos);
$totalRows_rsalumnos = mysql_num_rows($rsalumnos);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Codigo:</td>
<td><input type="text" name="codigo" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Nombre:</td>
<td><input type="text" name="nombre" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Apellidos:</td>
<td><input type="text" name="apellidos" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Nif:</td>
<td><input type="text" name="nif" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input type="submit" value="Insertar registro"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($rsalumnos);
?>
  #4 (permalink)  
Antiguo 03/11/2008, 17:03
Avatar de juaniquillo
Colaborador
 
Fecha de Ingreso: noviembre-2005
Ubicación: San Juan, Puerto Rico
Mensajes: 5.745
Antigüedad: 18 años, 5 meses
Puntos: 281
Respuesta: error: headers already sent

Intenta quitando el extra tag php de arriba

Código php:
Ver original
  1. <?php virtual('/sitiophp/Connections/conexcurso.php');
  2.  
  3. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  4. {
  5. $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
  6.  
  7. switch ($theType) {
  8. case "text":
  9. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  10. break;
  11. case "long":
  12. case "int":
  13. $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  14. break;
  15. case "double":
  16. $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
  17. break;
  18. case "date":
  19. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  20. break;
  21. case "defined":
  22. $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  23. break;
  24. }
  25. return $theValue;
  26. }
  27.  
  28. $editFormAction = $_SERVER['PHP_SELF'];
  29. if (isset($_SERVER['QUERY_STRING'])) {
  30. $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  31. }
  32.  
  33. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  34. $insertSQL = sprintf("INSERT INTO alumnos (codigo, nombre, apellidos, nif) VALUES (%s, %s, %s, %s)",
  35. GetSQLValueString($_POST['codigo'], "text"),
  36. GetSQLValueString($_POST['nombre'], "text"),
  37. GetSQLValueString($_POST['apellidos'], "text"),
  38. GetSQLValueString($_POST['nif'], "text"));
  39.  
  40. mysql_select_db($database_conexcurso, $conexcurso);
  41. $Result1 = mysql_query($insertSQL, $conexcurso) or die(mysql_error());
  42.  
  43. $insertGoTo = "/sitiophp/insertOK.php";
  44. if (isset($_SERVER['QUERY_STRING'])) {
  45. $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
  46. $insertGoTo .= $_SERVER['QUERY_STRING'];
  47. }
  48. header(sprintf("Location: %s", $insertGoTo));
  49. }
  50.  
  51. mysql_select_db($database_conexcurso, $conexcurso);
  52. $query_rsalumnos = "SELECT * FROM alumnos";
  53. $rsalumnos = mysql_query($query_rsalumnos, $conexcurso) or die(mysql_error());
  54. $row_rsalumnos = mysql_fetch_assoc($rsalumnos);
  55. $totalRows_rsalumnos = mysql_num_rows($rsalumnos);
  56. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  57. <html xmlns="http://www.w3.org/1999/xhtml">
  58. <head>
  59. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  60. <title>Documento sin t&iacute;tulo</title>
  61. </head>
  62.  
  63. <body>
  64. <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
  65. <table align="center">
  66. <tr valign="baseline">
  67. <td nowrap align="right">Codigo:</td>
  68. <td><input type="text" name="codigo" value="" size="32"></td>
  69. </tr>
  70. <tr valign="baseline">
  71. <td nowrap align="right">Nombre:</td>
  72. <td><input type="text" name="nombre" value="" size="32"></td>
  73. </tr>
  74. <tr valign="baseline">
  75. <td nowrap align="right">Apellidos:</td>
  76. <td><input type="text" name="apellidos" value="" size="32"></td>
  77. </tr>
  78. <tr valign="baseline">
  79. <td nowrap align="right">Nif:</td>
  80. <td><input type="text" name="nif" value="" size="32"></td>
  81. </tr>
  82. <tr valign="baseline">
  83. <td nowrap align="right">&nbsp;</td>
  84. <td><input type="submit" value="Insertar registro"></td>
  85. </tr>
  86. </table>
  87. <input type="hidden" name="MM_insert" value="form1">
  88. </form>
  89. <p>&nbsp;</p>
  90. </body>
  91. </html>
  92. <?php
  93. mysql_free_result($rsalumnos);
  94. ?>

Aunque yo no vi ningún espacio ahí.
__________________
Por fin.. tengo algo parecido a un blog
Y por lo visto ya estoy escribiendo...
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 11:46.