Ver Mensaje Individual
  #11 (permalink)  
Antiguo 09/07/2013, 16:32
raulgranadosraul
 
Fecha de Ingreso: julio-2013
Mensajes: 174
Antigüedad: 10 años, 10 meses
Puntos: 1
Respuesta: Problema con campo hidden en formulario

Cita:
Iniciado por Triby Ver Mensaje
Las líneas var_dump() son para poder ver lo que tienes y sí, son las causantes del error en el header(), una vez que resuelvas el problema del insert, las eliminas y listo!

Veamos tu consulta:
Código PHP:
Ver original
  1. $insertSQL = sprintf("INSERT INTO tblcomentarios (nombre, correo, telefono, mensaje, fecha, hora, idnoticia) VALUES (%s, %s, %s, %s, NOW(), CURRENT_TIME(), '". $id_not ."')",
  2.                        GetSQLValueString($_POST['nombre'], "text"),  // Primer %s
  3.                        GetSQLValueString($_POST['correo'], "text"),  // segundo %s
  4.                        GetSQLValueString($_POST['telefono'], "text"), // tercer %s
  5.                        GetSQLValueString($_POST['mensaje'], "text"), // cuarto %s
  6.                        GetSQLValueString($_POST['fecha'], "date"),  // No se necesita
  7.                        GetSQLValueString($_POST['hora'], "date"),  // Tampoco se necesita
  8.                        GetSQLValueString($_POST['idnoticia'], "int")); // Deberías tener otro %s
  9.  
  10. // Deberías tener:
  11.   $insertSQL = sprintf("INSERT INTO tblcomentarios (nombre, correo, telefono, mensaje, fecha, hora, idnoticia) VALUES (%s, %s, %s, %s, NOW(), CURRENT_TIME(), %s)",
  12.                        GetSQLValueString($_POST['nombre'], "text"),
  13.                        GetSQLValueString($_POST['correo'], "text"),
  14.                        GetSQLValueString($_POST['telefono'], "text"),
  15.                        GetSQLValueString($_POST['mensaje'], "text"),
  16.                        GetSQLValueString($_POST['idnoticia'], "int"));  // Quinto %s

Como ves, el error original es que estabas poniendo $id_not (variable no definida) directamente en la consulta y no era reemplazada con el contenido de $_POST['idnoticia'].

Deberías leer un poco acerca de la función [URL="http://www.php.net/manual/es/function.sprintf.php"]sprintf()[/URL] y no usarla a ciegas.

Muchas, muchas, muchas gracias (me faltarían líneas para darte las gracias, porque llevo con este problema un monton de dias. De veras, gracias.
SOLUCIONADO