27/07/2012, 04:29
|
| | | Fecha de Ingreso: abril-2008 Ubicación: Ibiza
Mensajes: 1.879
Antigüedad: 16 años, 1 mes Puntos: 326 | |
Respuesta: Concatenar variables de formulario Cita:
Iniciado por Zota Si eso hago pero me da el error Column 'GuiaMaestra' cannot be null
asi la he concatenado y nada que me funciona: Código PHP: <?php require_once('../../../../Connections/conex.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $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']); } $cadena=$_POST['CiudadOrigen'].$_POST['Numero'].$_POST['CiudadRecepcion']; if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO guia (Numero, GuiaMaestra, FechaEnvio, Remitente, Destinatario, TipoEnvio, Transporte, FechaLlegada, ConfirmaRecepcion, Prioridad, EstadoEnvio, Observacion, CiudadOrigen, CiudadRecepcion) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['Numero'], "text"), GetSQLValueString($_POST['GuiaMaestra'], "text"), GetSQLValueString($_POST['FechaEnvio'], "date"), GetSQLValueString($_POST['Remitente'], "text"), GetSQLValueString($_POST['Destinatario'], "text"), GetSQLValueString($_POST['TipoEnvio'], "text"), GetSQLValueString($_POST['Transporte'], "text"), GetSQLValueString($_POST['FechaLlegada'], "date"), GetSQLValueString($_POST['ConfirmaRecepcion'], "text"), GetSQLValueString($_POST['Prioridad'], "text"), GetSQLValueString($_POST['EstadoEnvio'], "text"), GetSQLValueString($_POST['Observacion'], "text"), GetSQLValueString($_POST['CiudadOrigen'], "text"), GetSQLValueString($_POST['CiudadRecepcion'], "text")); mysql_select_db($database_conex, $conex); $Result1 = mysql_query($insertSQL, $conex) or die(mysql_error());
me podrian ayudar por favor
Cambia esto: Código PHP: GetSQLValueString($_POST['GuiaMaestra'], "text"), Por esto.. Código PHP: GetSQLValueString($cadena, "text"), Ya que es es $cadena donde has hecho la concatenación ;) |