Foros del Web » Programando para Internet » PHP »

error al insertar formulario

Estas en el tema de error al insertar formulario en el foro de PHP en Foros del Web. Hola, tengo un problema en la pagina web, costatelde.es/insertar.php. Al enviar el formulario, se actualiza bien la base de datos, pero la web me devuelve ...
  #1 (permalink)  
Antiguo 21/08/2010, 05:50
 
Fecha de Ingreso: agosto-2008
Mensajes: 14
Antigüedad: 15 años, 8 meses
Puntos: 0
error al insertar formulario

Hola, tengo un problema en la pagina web, costatelde.es/insertar.php. Al enviar el formulario, se actualiza bien la base de datos, pero la web me devuelve este error:

Warning: Cannot modify header information - headers already sent by (output started at /mnt/web7/32/35/51740635/htdocs/costatelde/insertar.php:3) in /mnt/web7/32/35/51740635/htdocs/costatelde/insertar.php on line 157

¿Que me está queriendo decir?
Gracias a todos
  #2 (permalink)  
Antiguo 21/08/2010, 06:04
Avatar de gogupe  
Fecha de Ingreso: octubre-2006
Ubicación: Mallorca
Mensajes: 897
Antigüedad: 17 años, 6 meses
Puntos: 32
Respuesta: error al insertar formulario

Si no pones el código será muy dificil de decirte donde está el fallo.

Pero por el error que te da, es porque hay un output (has hecho un echo, print o cualquier salida a pantalla) en el fichero insertar.php linea 3.

El header debe de estar en lo más alto del código, que no haya anteriormente ninguna salida de información a la pantalla.

Busca por el foro, porque este fallo es muy muy muuuuy común.
  #3 (permalink)  
Antiguo 21/08/2010, 06:06
 
Fecha de Ingreso: agosto-2008
Mensajes: 14
Antigüedad: 15 años, 8 meses
Puntos: 0
Respuesta: error al insertar formulario

gracias, miraré a ver, el caso es que en el servidor local si va bien, y en la web no.
  #4 (permalink)  
Antiguo 21/08/2010, 09:07
 
Fecha de Ingreso: agosto-2010
Mensajes: 79
Antigüedad: 13 años, 8 meses
Puntos: 2
Respuesta: error al insertar formulario

es como te dijeron... cuando haces un print... un echo o lo que sea... el interprete manda lo headers del http1.1 y comienza a mandar los datos... si vos ahi le queres pasar un header nuevo el interprete te putea porque ya le pediste (indirectamente) que los mande antes.
  #5 (permalink)  
Antiguo 21/08/2010, 12:48
 
Fecha de Ingreso: agosto-2008
Mensajes: 14
Antigüedad: 15 años, 8 meses
Puntos: 0
Respuesta: error al insertar formulario

El código es el siguiente:

<?php require_once('Connections/cnx.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 inmueble (zonaID, tipoID, estadoID, titulo, dimensiones, habitaciones, aseos, garaje, detalle, precio, fotoprincipal, foto1, foto2, foto3, foto4, nombre, telefono1, telefono2, direccion, observaciones) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['zonaID'], "int"),
GetSQLValueString($_POST['tipoID'], "int"),
GetSQLValueString($_POST['estadoID'], "int"),
GetSQLValueString($_POST['titulo'], "text"),
GetSQLValueString($_POST['dimensiones'], "text"),
GetSQLValueString($_POST['habitaciones'], "text"),
GetSQLValueString($_POST['aseos'], "text"),
GetSQLValueString($_POST['garaje'], "text"),
GetSQLValueString($_POST['detalle'], "text"),
GetSQLValueString($_POST['precio'], "double"),
GetSQLValueString($_FILES['fotoprincipal']['name'], "text"),
GetSQLValueString($_FILES['foto1']['name'], "text"),
GetSQLValueString($_FILES['foto2']['name'], "text"),
GetSQLValueString($_FILES['foto3']['name'], "text"),
GetSQLValueString($_FILES['foto4']['name'], "text"),
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['telefono1'], "int"),
GetSQLValueString($_POST['telefono2'], "int"),
GetSQLValueString($_POST['direccion'], "text"),
GetSQLValueString($_POST['observaciones'], "text"));

mysql_select_db($database_cnx, $cnx);
$Result1 = mysql_query($insertSQL, $cnx) or die(mysql_error());

$destino="images/recibidas/fotoprincipal/";
copy($_FILES['fotoprincipal']['tmp_name'],$destino.$_FILES['fotoprincipal']['name']);

$destino="images/recibidas/";
copy($_FILES['foto1']['tmp_name'],$destino.$_FILES['foto1']['name']);
copy($_FILES['foto2']['tmp_name'],$destino.$_FILES['foto2']['name']);
copy($_FILES['foto3']['tmp_name'],$destino.$_FILES['foto3']['name']);
copy($_FILES['foto4']['tmp_name'],$destino.$_FILES['foto4']['name']);

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

mysql_select_db($database_cnx, $cnx);
$query_rsZonaID = "SELECT * FROM inmueble_zona ORDER BY zona ASC";
$rsZonaID = mysql_query($query_rsZonaID, $cnx) or die(mysql_error());
$row_rsZonaID = mysql_fetch_assoc($rsZonaID);
$totalRows_rsZonaID = mysql_num_rows($rsZonaID);

mysql_select_db($database_cnx, $cnx);
$query_rsTipo = "SELECT * FROM inmueble_tipo ORDER BY tipo ASC";
$rsTipo = mysql_query($query_rsTipo, $cnx) or die(mysql_error());
$row_rsTipo = mysql_fetch_assoc($rsTipo);
$totalRows_rsTipo = mysql_num_rows($rsTipo);

mysql_select_db($database_cnx, $cnx);
$query_rsEstado = "SELECT * FROM inmueble_estado ORDER BY estado ASC";
$rsEstado = mysql_query($query_rsEstado, $cnx) or die(mysql_error());
$row_rsEstado = mysql_fetch_assoc($rsEstado);
$totalRows_rsEstado = mysql_num_rows($rsEstado);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<div id="cabecera">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/plantilla.dwt" codeOutsideHTMLIsLocked="false" -->
<head>

<link href='icono.ico' rel='icon' type='image/x-ico'/>
<link href='icono.ico' rel='shortcut icon' type='image/x-ico'/>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Contactar con Costa Telde</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->

<link href="style.css" rel="stylesheet" type="text/css" />

<meta name="Description" content=""/>

<meta name="keywords" content="" />

</head>

<body>.....
  #6 (permalink)  
Antiguo 21/08/2010, 18:36
 
Fecha de Ingreso: agosto-2008
Mensajes: 14
Antigüedad: 15 años, 8 meses
Puntos: 0
Respuesta: error al insertar formulario

Gracias, ya funciona de nuevo!

Etiquetas: formulario
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 01:49.