11/10/2008, 12:00
|
| | | Fecha de Ingreso: mayo-2005 Ubicación: Medellin - Colombia
Mensajes: 1.797
Antigüedad: 19 años, 8 meses Puntos: 394 | |
Problemas con inserción de registro estoy intentando realizar un insert en mi base de datos pero no me quiere funcionar... este es el insert...
Código:
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']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form_ins_pauta")) {
$insertSQL = sprintf("INSERT INTO reg_event (nit, titulo, descripcion, lugar, entrada, tipos, ciudad, f_inicio, f_fin, fecha_ingreso, url, correo, tel_info1, tel_info2, dir, horario, precio, hora_fun, zona_barrio) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['nit'], "int"),
GetSQLValueString($_POST['titulo'], "text"),
GetSQLValueString($_POST['descripcion'], "text"),
GetSQLValueString($_POST['lugar'], "text"),
GetSQLValueString($_POST['entrada'], "int"),
GetSQLValueString($tipos, "int"),
GetSQLValueString($_POST['ciudad'], "text"),
GetSQLValueString($tipos, "text"),
GetSQLValueString($_POST['ciudad'], "text"),
GetSQLValueString($_POST['f_inicio'], "date"),
GetSQLValueString($_POST['f_fin'], "date"),
GetSQLValueString($_POST['fecha_ingreso'], "date"),
GetSQLValueString($_POST['url'], "text"),
GetSQLValueString($_POST['correo'], "text"),
GetSQLValueString($_POST['tel_info1'], "text"),
GetSQLValueString($_POST['tel_info2'], "text"),
GetSQLValueString($_POST['dir'], "text"),
GetSQLValueString($_POST['horario'], "text"),
GetSQLValueString($_POST['precio'], "text"),
GetSQLValueString($hora_fun, "text"),
GetSQLValueString($_POST['zona_barrio'], "text"));
mysql_select_db($database_conectar, $conectar);
$Result1 = mysql_query($insertSQL, $conectar) or die(mysql_error());
$insertGoTo = "reg_event_exitoso.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
Y este es el campo que me genera el problema... Código HTML: <input name="zona_barrio" type="text" size="50" maxlength="50" /> Y el error que me sale dice q el campo zona_barrio no puede ser nulo aun cuando si tiene contenido... realizo un echo a esta variable cuando el usuario le da enviar y me imprime el texto que el usuario ingreso...
error
Código:
Column 'zona_barrio' cannot be null
Muchas gracias por su ayuda...
__________________ Por que existe gente que no agradece después de que se le ha brindado tiempo y ayuda ??? |