Ver Mensaje Individual
  #3 (permalink)  
Antiguo 17/09/2010, 02:56
tonimito
 
Fecha de Ingreso: diciembre-2003
Mensajes: 157
Antigüedad: 20 años, 4 meses
Puntos: 1
Respuesta: Menu <select> para actualizar campo en BD compuesto de Foreign Keys

Cita:
Iniciado por angelAparicio Ver Mensaje
Posiblemente estés cogiendo mal el valor que envía el select. ¿Código?
Aquí va:

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

if ((isset(
$_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  
$updateSQL sprintf("UPDATE productores SET es_NombreProductor=%s, es_Comunidad=%s, es_Ciudad=%s, es_TextoIntro=%s, es_Texto=%s, es_H1=%s, es_Title=%s, es_Description=%s, es_Keywords=%s, es_URL=%s, es_CentroProduccion=%s, es_CentroProduccion_Texto=%s, es_CentroProduccion_Title=%s, es_CentroProduccion_Description=%s, es_CentroProduccion_Keywords=%s, es_CentroProduccion_URL=%s, es_CentroProduccion_H1=%s, ca_NombreProductor=%s, ca_Comunidad=%s, ca_Ciudad=%s, ca_TextoIntro=%s, ca_Texto=%s, ca_H1=%s, ca_Title=%s, ca_Description=%s, ca_Keywords=%s, ca_URL=%s, ca_CentroProduccion=%s, ca_CentroProduccion_Texto=%s, ca_CentroProduccion_Title=%s, ca_CentroProduccion_Description=%s, ca_CentroProduccion_Keywords=%s, ca_CentroProduccion_URL=%s, ca_CentroProduccion_H1=%s, Imagen=%s WHERE Id_Productor=%s",
                       
GetSQLValueString($_POST['es_NombreProductor'], "text"),
                       
GetSQLValueString($_POST['es_Comunidad'], "double"),
                       
GetSQLValueString($_POST['es_Ciudad'], "text"),
                       
GetSQLValueString($_POST['es_TextoIntro'], "text"),
                       
GetSQLValueString($_POST['es_Texto'], "text"),
                       
GetSQLValueString($_POST['es_H1'], "text"),
                       
GetSQLValueString($_POST['es_Title'], "text"),
                       
GetSQLValueString($_POST['es_Description'], "text"),
                       
GetSQLValueString($_POST['es_Keywords'], "text"),
                       
GetSQLValueString($_POST['es_URL'], "text"),
                       
GetSQLValueString($_POST['es_CentroProduccion'], "text"),
                       
GetSQLValueString($_POST['es_CentroProduccion_Texto'], "text"),
                       
GetSQLValueString($_POST['es_CentroProduccion_Title'], "text"),
                       
GetSQLValueString($_POST['es_CentroProduccion_Description'], "text"),
                       
GetSQLValueString($_POST['es_CentroProduccion_Keywords'], "text"),
                       
GetSQLValueString($_POST['es_CentroProduccion_URL'], "text"),
                       
GetSQLValueString($_POST['es_CentroProduccion_H1'], "text"),
                       
GetSQLValueString($_POST['ca_NombreProductor'], "text"),
                       
GetSQLValueString($_POST['ca_Comunidad'], "double"),
                       
GetSQLValueString($_POST['ca_Ciudad'], "text"),
                       
GetSQLValueString($_POST['ca_TextoIntro'], "text"),
                       
GetSQLValueString($_POST['ca_Texto'], "text"),
                       
GetSQLValueString($_POST['ca_H1'], "text"),
                       
GetSQLValueString($_POST['ca_Title'], "text"),
                       
GetSQLValueString($_POST['ca_Description'], "text"),
                       
GetSQLValueString($_POST['ca_Keywords'], "text"),
                       
GetSQLValueString($_POST['ca_URL'], "text"),
                       
GetSQLValueString($_POST['ca_CentroProduccion'], "text"),
                       
GetSQLValueString($_POST['ca_CentroProduccion_Texto'], "text"),
                       
GetSQLValueString($_POST['ca_CentroProduccion_Title'], "text"),
                       
GetSQLValueString($_POST['ca_CentroProduccion_Description'], "text"),
                       
GetSQLValueString($_POST['ca_CentroProduccion_Keywords'], "text"),
                       
GetSQLValueString($_POST['ca_CentroProduccion_URL'], "text"),
                       
GetSQLValueString($_POST['ca_CentroProduccion_H1'], "text"),
                       
GetSQLValueString($_POST['Imagen'], "text"),
                       
GetSQLValueString($_POST['Id_Productor'], "int"));

  
mysql_select_db($database_bdmontsoliu$bdmontsoliu);
  
$Result1 mysql_query($updateSQL$bdmontsoliu) or die(mysql_error());

  
$updateGoTo 'http://www.web.com/gestor/seo/productores/'.$Edicion.'/ok/';
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$updateGoTo .= (strpos($updateGoTo'?'));
    
$updateGoTo .= preg_replace('/Edicion='.$Edicion.'&Id=/'''$_SERVER['QUERY_STRING']);
  }
  
header(sprintf("Location: %s"$updateGoTo));

Y me da el fallo

Cannot add or update a child row: a foreign key constraint fails (`montsoliudemo`.`productores`, CONSTRAINT `es_Comunidad` FOREIGN KEY (`es_Comunidad`) REFERENCES `productos-comunidad` (`es_Comunidad`) ON DELETE NO ACTION ON UPDATE CASCADE)

Supongo que el fallo andará por aquí...

Última edición por tonimito; 17/09/2010 a las 03:25