Foros del Web » Programando para Internet » PHP »

sos con esto error

Estas en el tema de sos con esto error en el foro de PHP en Foros del Web. Necesito saber si tengo algun fallo en el codigo fuente tras insertar un registro me sale este error : Warning: Cannot modify header information - ...
  #1 (permalink)  
Antiguo 21/04/2014, 09:46
 
Fecha de Ingreso: marzo-2010
Mensajes: 8
Antigüedad: 14 años
Puntos: 0
sos con esto error

Necesito saber si tengo algun fallo en el codigo fuente tras insertar un registro me sale este

error :

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\webdefinitiva\includes\slider.php: 55) in C:\xampp\htdocs\webdefinitiva\includes\registro.ph p on line 54


os pongo el codigo fuente :

<?php require_once('Connections/registrodb.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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 registrodb (Nombre, Email, Usuario, Password) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['Nombre'], "text"),
GetSQLValueString($_POST['Email'], "text"),
GetSQLValueString($_POST['Usuario'], "text"),
GetSQLValueString($_POST['Password'], "text"));

mysql_select_db($database_registrodb, $registrodb);
$Result1 = mysql_query($insertSQL, $registrodb) or die(mysql_error());

$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo)); Aquí En esta linea da el error
}
?>

<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Nombre:</td>
<td><input type="text" name="Nombre" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Email:</td>
<td><input type="text" name="Email" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Usuario:</td>
<td><input type="text" name="Usuario" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Password:</td>
<td><input type="password" name="Password" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><a class="button" href="javascript:document.form1.submit();"><span>I nsertar Slider</span></a></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>

Me gustaria saber si debo cambiar algo o si necesitais algo mas.

Muchas gracias El saber es poder
  #2 (permalink)  
Antiguo 21/04/2014, 09:52
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: sos con esto error

Claro que hay fallo, lee lo siguiente: PHP:¿Por qué me sale "Warning: Cannot modify header information - headers already sent by (output started at 1:2) in 3 on line 4"?

PDTA: por favor lee las normas del foro y aprende a buscar antes de repetir algún tema.
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 21/04/2014, 10:45
Avatar de Italico76  
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años
Puntos: 292
Respuesta: sos con esto error

No puedes sacar nada "por pantalla" antes de session_start() .. ni siquiera un espacio...... y eso vale igual si estas incluyendo un archivo que envia asi sea un espacio al navegador y luego viene en ese o en el que lo incluyo session_start()
__________________
Salu2!

Etiquetas: html, mysql, registro, select, sos, sql
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 05:08.