Foros del Web » Programando para Internet » PHP »

Enviando campos vacios de form a DB

Estas en el tema de Enviando campos vacios de form a DB en el foro de PHP en Foros del Web. Saludos, Tengo un problema y una pregunta que hacer... Estoy haciendo unos formularios de ingreso de usuarios e inserta a la perfección, pero si dejo ...
  #1 (permalink)  
Antiguo 17/03/2008, 09:07
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Enviando campos vacios de form a DB

Saludos,
Tengo un problema y una pregunta que hacer...
Estoy haciendo unos formularios de ingreso de usuarios e inserta a la perfección, pero si dejo algun campo en blanco me dice "columm X cannot be NULL"
alguien puede decirme que debo hacer en ese caso???... para que no diga eso cuando el usuario deje de ingresar campos...

Gracias!!!
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #2 (permalink)  
Antiguo 17/03/2008, 09:10
Avatar de eft0  
Fecha de Ingreso: junio-2003
Ubicación: Santiago - Chile
Mensajes: 635
Antigüedad: 20 años, 10 meses
Puntos: 9
Re: Enviando campos vacios de form a DB

Es por que el tipo de datos esta declarado como NOT NULL. No escribas el campo en la sentencia SQL, o bien asiganle un valor en blanco.
  #3 (permalink)  
Antiguo 17/03/2008, 09:24
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Re: Enviando campos vacios de form a DB

Cita:
Iniciado por eft0 Ver Mensaje
Es por que el tipo de datos esta declarado como NOT NULL. No escribas el campo en la sentencia SQL, o bien asiganle un valor en blanco.
No escribas el campo en la sentencia SQL, o bien asiganle un valor en blanco

como por ejemplo??? soy un poco novato y lo estoy haciendo por dreamweaver
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #4 (permalink)  
Antiguo 17/03/2008, 09:30
Avatar de eft0  
Fecha de Ingreso: junio-2003
Ubicación: Santiago - Chile
Mensajes: 635
Antigüedad: 20 años, 10 meses
Puntos: 9
Re: Enviando campos vacios de form a DB

Postea el query para ver que tienes que modificar.
  #5 (permalink)  
Antiguo 17/03/2008, 09:32
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Re: Enviando campos vacios de form a DB

Código PHP:
<?php require_once('Connections/flamuko.php'); ?>
<?php
include_once("fckeditor/fckeditor.php") ;
?>
<?php
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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")) {

$ediciondir'../imgprod/';  
$uploaddir=$ediciondir;
if (!
is_dir($ediciondir)) {     mkdir($uploaddir0777);    }
move_uploaded_file($_FILES['imagen']['tmp_name'], $uploaddir $_FILES['imagen']['name']);    
$filename $_FILES['imagen']['name'];


$insertSQL sprintf("INSERT INTO productos (id_cat, id_sub, id_lin, nombre, codigo, descripcion, imagen) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['id_cat'], "int"),
                       
GetSQLValueString($_POST['id_sub'], "int"),
                       
GetSQLValueString($_POST['id_lin'], "int"),
                       
GetSQLValueString($_POST['nombre'], "text"),
                       
GetSQLValueString($_POST['codigo'], "text"),
                       
GetSQLValueString($_POST['descripcion'], "text"),
                       
GetSQLValueString($filename"text"));

  
mysql_select_db($database_flamuko$flamuko);
  
$Result1 mysql_query($insertSQL$flamuko) or die(mysql_error());

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

mysql_select_db($database_flamuko$flamuko);
$query_Recordset1 "SELECT * FROM categoria";
$Recordset1 mysql_query($query_Recordset1$flamuko) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);

mysql_select_db($database_flamuko$flamuko);
$query_Recordset2 "SELECT * FROM subcategoria";
$Recordset2 mysql_query($query_Recordset2$flamuko) or die(mysql_error());
$row_Recordset2 mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 mysql_num_rows($Recordset2);

mysql_select_db($database_flamuko$flamuko);
$query_Recordset3 "SELECT * FROM linea";
$Recordset3 mysql_query($query_Recordset3$flamuko) or die(mysql_error());
$row_Recordset3 mysql_fetch_assoc($Recordset3);
$totalRows_Recordset3 mysql_num_rows($Recordset3);

?>
la idea es q cuando yo no quiera enviar el codigo del producto no lo ingrese y listo!!!!
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #6 (permalink)  
Antiguo 17/03/2008, 09:36
Avatar de eft0  
Fecha de Ingreso: junio-2003
Ubicación: Santiago - Chile
Mensajes: 635
Antigüedad: 20 años, 10 meses
Puntos: 9
Re: Enviando campos vacios de form a DB

En la funcion GetSQLValueString() reemplaza todo lo "NULL" por "".
  #7 (permalink)  
Antiguo 17/03/2008, 09:39
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Re: Enviando campos vacios de form a DB

Cita:
Iniciado por eft0 Ver Mensaje
En la funcion GetSQLValueString() reemplaza todo lo "NULL" por "".
ok entonces cuando yo deje el campo en blanco ya no me dara el error cierto?
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #8 (permalink)  
Antiguo 17/03/2008, 13:26
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Re: Enviando campos vacios de form a DB

lo hice y me da error con la version de SQL
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #9 (permalink)  
Antiguo 17/03/2008, 14:32
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Re: Enviando campos vacios de form a DB

aqui dejo la declaracion de SQL y eso... lo hice por dreamweaver...

Código PHP:
<?php require_once('../Connections/pintor.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']);
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  
$insertSQL sprintf("INSERT INTO rrhh (id, nombres, apellidos, email, pais, estado, ciudad, urbanizacion, calle, casa, piso, telcasa, telcelular, nacionalidad, cedpas, numerodoc, fechanac, sexo, estadocivil, objetivos, cargo, puesto, tipotrabajo, sueldo, cambiociudad, desde, hasta, empresa, dir_empresa, cargo_empresa, jefe, cargo_jefe, terminacion, sueldo_final, desde2, hasta2, empresa2, dir_empresa2, cargo_empresa2, jefe2, cargo_jefe2, terminacion2, sueldo_final2, desde3, hasta3, empresa3, dir_empresa3, cargo_empresa3, jefe3, cargo_jefe3, terminacion3, sueldo_final3, instituto, dir_instituto, anos_cur, inicio_inst, final_inst, titulo, instituto2, dir_instituto2, anos_cur2, inicio_inst2, final_inst2, titulo2, instituto3, dir_instituto3, anos_cur3, inicio_cur3, final_cur3, titulo3, instituto4, dir_instituto4, anos_cur4, inicio_inst4, final_inst4, titulo4, instituto5, dir_instituto5, anos_cur5, inicio_inst5, final_inst5, titulo5, nomape, direccion_ref, tel_ref, tiempo_ref, nomape2, direccion_ref2, tel_ref2, tiempo_ref2) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['id'], "int"),
                       
GetSQLValueString($_POST['nombres'], "text"),
                       
GetSQLValueString($_POST['apellidos'], "text"),
                       
GetSQLValueString($_POST['email'], "text"),
                       
GetSQLValueString($_POST['pais'], "text"),
                       
GetSQLValueString($_POST['estado'], "text"),
                       
GetSQLValueString($_POST['ciudad'], "text"),
                       
GetSQLValueString($_POST['urbanizacion'], "text"),
                       
GetSQLValueString($_POST['calle'], "text"),
                       
GetSQLValueString($_POST['casa'], "text"),
                       
GetSQLValueString($_POST['piso'], "text"),
                       
GetSQLValueString($_POST['telcasa'], "text"),
                       
GetSQLValueString($_POST['telcelular'], "text"),
                       
GetSQLValueString($_POST['nacionalidad'], "text"),
                       
GetSQLValueString($_POST['cedpas'], "text"),
                       
GetSQLValueString($_POST['numerodoc'], "text"),
                       
GetSQLValueString($_POST['fechanac'], "date"),
                       
GetSQLValueString($_POST['sexo'], "text"),
                       
GetSQLValueString($_POST['estadocivil'], "text"),
                       
GetSQLValueString($_POST['objetivos'], "text"),
                       
GetSQLValueString($_POST['cargo'], "text"),
                       
GetSQLValueString($_POST['puesto'], "text"),
                       
GetSQLValueString($_POST['tipotrabajo'], "text"),
                       
GetSQLValueString($_POST['sueldo'], "text"),
                       
GetSQLValueString($_POST['cambiociudad'], "text"),
                       
GetSQLValueString($_POST['desde'], "text"),
                       
GetSQLValueString($_POST['hasta'], "text"),
                       
GetSQLValueString($_POST['empresa'], "text"),
                       
GetSQLValueString($_POST['dir_empresa'], "text"),
                       
GetSQLValueString($_POST['cargo_empresa'], "text"),
                       
GetSQLValueString($_POST['jefe'], "text"),
                       
GetSQLValueString($_POST['cargo_jefe'], "text"),
                       
GetSQLValueString($_POST['terminacion'], "text"),
                       
GetSQLValueString($_POST['sueldo_final'], "text"),
                       
GetSQLValueString($_POST['desde2'], "text"),
                       
GetSQLValueString($_POST['hasta2'], "text"),
                       
GetSQLValueString($_POST['empresa2'], "text"),
                       
GetSQLValueString($_POST['dir_empresa2'], "text"),
                       
GetSQLValueString($_POST['cargo_empresa2'], "text"),
                       
GetSQLValueString($_POST['jefe2'], "text"),
                       
GetSQLValueString($_POST['cargo_jefe2'], "text"),
                       
GetSQLValueString($_POST['terminacion2'], "text"),
                       
GetSQLValueString($_POST['sueldo_final2'], "text"),
                       
GetSQLValueString($_POST['desde3'], "text"),
                       
GetSQLValueString($_POST['hasta3'], "text"),
                       
GetSQLValueString($_POST['empresa3'], "text"),
                       
GetSQLValueString($_POST['dir_empresa3'], "text"),
                       
GetSQLValueString($_POST['cargo_empresa3'], "text"),
                       
GetSQLValueString($_POST['jefe3'], "text"),
                       
GetSQLValueString($_POST['cargo_jefe3'], "text"),
                       
GetSQLValueString($_POST['terminacion3'], "text"),
                       
GetSQLValueString($_POST['sueldo_final3'], "text"),
                       
GetSQLValueString($_POST['instituto'], "text"),
                       
GetSQLValueString($_POST['dir_instituto'], "text"),
                       
GetSQLValueString($_POST['anos_cur'], "text"),
                       
GetSQLValueString($_POST['inicio_inst'], "text"),
                       
GetSQLValueString($_POST['final_inst'], "text"),
                       
GetSQLValueString($_POST['titulo'], "text"),
                       
GetSQLValueString($_POST['instituto2'], "text"),
                       
GetSQLValueString($_POST['dir_instituto2'], "text"),
                       
GetSQLValueString($_POST['anos_cur2'], "text"),
                       
GetSQLValueString($_POST['inicio_inst2'], "text"),
                       
GetSQLValueString($_POST['final_inst2'], "text"),
                       
GetSQLValueString($_POST['titulo2'], "text"),
                       
GetSQLValueString($_POST['instituto3'], "text"),
                       
GetSQLValueString($_POST['dir_instituto3'], "text"),
                       
GetSQLValueString($_POST['anos_cur3'], "text"),
                       
GetSQLValueString($_POST['inicio_cur3'], "text"),
                       
GetSQLValueString($_POST['final_cur3'], "text"),
                       
GetSQLValueString($_POST['titulo3'], "text"),
                       
GetSQLValueString($_POST['instituto4'], "text"),
                       
GetSQLValueString($_POST['dir_instituto4'], "text"),
                       
GetSQLValueString($_POST['anos_cur4'], "text"),
                       
GetSQLValueString($_POST['inicio_inst4'], "text"),
                       
GetSQLValueString($_POST['final_inst4'], "text"),
                       
GetSQLValueString($_POST['titulo4'], "text"),
                       
GetSQLValueString($_POST['instituto5'], "text"),
                       
GetSQLValueString($_POST['dir_instituto5'], "text"),
                       
GetSQLValueString($_POST['anos_cur5'], "text"),
                       
GetSQLValueString($_POST['inicio_inst5'], "text"),
                       
GetSQLValueString($_POST['final_inst5'], "text"),
                       
GetSQLValueString($_POST['titulo5'], "text"),
                       
GetSQLValueString($_POST['nomape'], "text"),
                       
GetSQLValueString($_POST['direccion_ref'], "text"),
                       
GetSQLValueString($_POST['tel_ref'], "text"),
                       
GetSQLValueString($_POST['tiempo_ref'], "text"),
                       
GetSQLValueString($_POST['nomape2'], "text"),
                       
GetSQLValueString($_POST['direccion_ref2'], "text"),
                       
GetSQLValueString($_POST['tel_ref2'], "text"),
                       
GetSQLValueString($_POST['tiempo_ref2'], "text"));

  
mysql_select_db($database_pintor$pintor);
  
$Result1 mysql_query($insertSQL$pintor) or die(mysql_error());
}
?>
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #10 (permalink)  
Antiguo 17/03/2008, 15:57
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Re: Enviando campos vacios de form a DB

En ese código que publicas no haz dicho lo que te dijo eft0 de cambiar todos los "NULL" por "".

Saludos.
  #11 (permalink)  
Antiguo 17/03/2008, 16:22
Avatar de lucasan
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: Cali - Colombia
Mensajes: 1.144
Antigüedad: 16 años, 10 meses
Puntos: 59
Re: Enviando campos vacios de form a DB

Lo que te dice es que el valor no puede ser vacio, haz lo que te han dicho y cambi a"NULL" por "" y te debe funcionar.

Saludos
__________________
Plan Original Desarrollo Web
~$>sudo apt-get install -f
"Asi debería arreglarse todo en la vida"
  #12 (permalink)  
Antiguo 17/03/2008, 16:57
Avatar de jaronu  
Fecha de Ingreso: febrero-2008
Mensajes: 2.183
Antigüedad: 16 años, 2 meses
Puntos: 52
Re: Enviando campos vacios de form a DB

Hola, es que tengo una duda con este tema,

en el form que tiene T4ke0veR co quitar lo de "NULL" a "" es suficiente para que si se queda vacio un campo del form no pase nada al insertar los demas datos en la BD,

Se podria hacer lo mismo con este form, si dejo cualquier campo vacio que inserte bien los demas datos en la BD, es que si dejo uno vacio no guarda ningun dato en la Base y eso que no da error ni nada, simplemente no sube.

Código PHP:
<form action="<?php echo $_SERVER['PHP_SELF'?>" method="post" enctype="multipart/form-data"> 
    <p>Archivo 1: 
      <input name="fichero" type="file" size="150" maxlength="150"> 
      <br> 
      Nombre: 
      <input name="nombre_archivo" type="text" size="70" maxlength="70">
      <br> 
      Descripcion: 
      <input name="description" type="text" size="100" maxlength="250">
    </p>
    <p>Categoria:
      <label>
      <input type="text" name="cat" id="cat">
      </label>
      <br><br><br>
  <p>Archivo 2: 
      <input name="fichero2" type="file" size="150" maxlength="150"> 
      <br> 
      Nombre2: 
      <input name="nombre_archivo2" type="text" size="70" maxlength="70">
      <br>
  </p>
    <p><br>
      <input name="submit" type="submit" value="Upload!">  
  </p>
</form>
  #13 (permalink)  
Antiguo 18/03/2008, 06:49
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Re: Enviando campos vacios de form a DB

ok lo hice y me dice esto

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' , , , 'Afganistán', , , , , , , , , , 'cedula', , 'menuitem1', 'Masculino', 'S' at line 1

Código PHP:
<?php require_once('../Connections/pintor.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 "'" "";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "";
      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 rrhh (id, nombres, apellidos, email, pais, estado, ciudad, urbanizacion, calle, casa, piso, telcasa, telcelular, nacionalidad, cedpas, numerodoc, fechanac, sexo, estadocivil, objetivos, cargo, puesto, tipotrabajo, sueldo, cambiociudad, desde, hasta, empresa, dir_empresa, cargo_empresa, jefe, cargo_jefe, terminacion, sueldo_final, desde2, hasta2, empresa2, dir_empresa2, cargo_empresa2, jefe2, cargo_jefe2, terminacion2, sueldo_final2, desde3, hasta3, empresa3, dir_empresa3, cargo_empresa3, jefe3, cargo_jefe3, terminacion3, sueldo_final3, instituto, dir_instituto, anos_cur, inicio_inst, final_inst, titulo, instituto2, dir_instituto2, anos_cur2, inicio_inst2, final_inst2, titulo2, instituto3, dir_instituto3, anos_cur3, inicio_cur3, final_cur3, titulo3, instituto4, dir_instituto4, anos_cur4, inicio_inst4, final_inst4, titulo4, instituto5, dir_instituto5, anos_cur5, inicio_inst5, final_inst5, titulo5, nomape, direccion_ref, tel_ref, tiempo_ref, nomape2, direccion_ref2, tel_ref2, tiempo_ref2) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['id'], "int"),
                       
GetSQLValueString($_POST['nombres'], "text"),
                       
GetSQLValueString($_POST['apellidos'], "text"),
                       
GetSQLValueString($_POST['email'], "text"),
                       
GetSQLValueString($_POST['pais'], "text"),
                       
GetSQLValueString($_POST['estado'], "text"),
                       
GetSQLValueString($_POST['ciudad'], "text"),
                       
GetSQLValueString($_POST['urbanizacion'], "text"),
                       
GetSQLValueString($_POST['calle'], "text"),
                       
GetSQLValueString($_POST['casa'], "text"),
                       
GetSQLValueString($_POST['piso'], "text"),
                       
GetSQLValueString($_POST['telcasa'], "text"),
                       
GetSQLValueString($_POST['telcelular'], "text"),
                       
GetSQLValueString($_POST['nacionalidad'], "text"),
                       
GetSQLValueString($_POST['cedpas'], "text"),
                       
GetSQLValueString($_POST['numerodoc'], "text"),
                       
GetSQLValueString($_POST['fechanac'], "date"),
                       
GetSQLValueString($_POST['sexo'], "text"),
                       
GetSQLValueString($_POST['estadocivil'], "text"),
                       
GetSQLValueString($_POST['objetivos'], "text"),
                       
GetSQLValueString($_POST['cargo'], "text"),
                       
GetSQLValueString($_POST['puesto'], "text"),
                       
GetSQLValueString($_POST['tipotrabajo'], "text"),
                       
GetSQLValueString($_POST['sueldo'], "text"),
                       
GetSQLValueString($_POST['cambiociudad'], "text"),
                       
GetSQLValueString($_POST['desde'], "text"),
                       
GetSQLValueString($_POST['hasta'], "text"),
                       
GetSQLValueString($_POST['empresa'], "text"),
                       
GetSQLValueString($_POST['dir_empresa'], "text"),
                       
GetSQLValueString($_POST['cargo_empresa'], "text"),
                       
GetSQLValueString($_POST['jefe'], "text"),
                       
GetSQLValueString($_POST['cargo_jefe'], "text"),
                       
GetSQLValueString($_POST['terminacion'], "text"),
                       
GetSQLValueString($_POST['sueldo_final'], "text"),
                       
GetSQLValueString($_POST['desde2'], "text"),
                       
GetSQLValueString($_POST['hasta2'], "text"),
                       
GetSQLValueString($_POST['empresa2'], "text"),
                       
GetSQLValueString($_POST['dir_empresa2'], "text"),
                       
GetSQLValueString($_POST['cargo_empresa2'], "text"),
                       
GetSQLValueString($_POST['jefe2'], "text"),
                       
GetSQLValueString($_POST['cargo_jefe2'], "text"),
                       
GetSQLValueString($_POST['terminacion2'], "text"),
                       
GetSQLValueString($_POST['sueldo_final2'], "text"),
                       
GetSQLValueString($_POST['desde3'], "text"),
                       
GetSQLValueString($_POST['hasta3'], "text"),
                       
GetSQLValueString($_POST['empresa3'], "text"),
                       
GetSQLValueString($_POST['dir_empresa3'], "text"),
                       
GetSQLValueString($_POST['cargo_empresa3'], "text"),
                       
GetSQLValueString($_POST['jefe3'], "text"),
                       
GetSQLValueString($_POST['cargo_jefe3'], "text"),
                       
GetSQLValueString($_POST['terminacion3'], "text"),
                       
GetSQLValueString($_POST['sueldo_final3'], "text"),
                       
GetSQLValueString($_POST['instituto'], "text"),
                       
GetSQLValueString($_POST['dir_instituto'], "text"),
                       
GetSQLValueString($_POST['anos_cur'], "text"),
                       
GetSQLValueString($_POST['inicio_inst'], "text"),
                       
GetSQLValueString($_POST['final_inst'], "text"),
                       
GetSQLValueString($_POST['titulo'], "text"),
                       
GetSQLValueString($_POST['instituto2'], "text"),
                       
GetSQLValueString($_POST['dir_instituto2'], "text"),
                       
GetSQLValueString($_POST['anos_cur2'], "text"),
                       
GetSQLValueString($_POST['inicio_inst2'], "text"),
                       
GetSQLValueString($_POST['final_inst2'], "text"),
                       
GetSQLValueString($_POST['titulo2'], "text"),
                       
GetSQLValueString($_POST['instituto3'], "text"),
                       
GetSQLValueString($_POST['dir_instituto3'], "text"),
                       
GetSQLValueString($_POST['anos_cur3'], "text"),
                       
GetSQLValueString($_POST['inicio_cur3'], "text"),
                       
GetSQLValueString($_POST['final_cur3'], "text"),
                       
GetSQLValueString($_POST['titulo3'], "text"),
                       
GetSQLValueString($_POST['instituto4'], "text"),
                       
GetSQLValueString($_POST['dir_instituto4'], "text"),
                       
GetSQLValueString($_POST['anos_cur4'], "text"),
                       
GetSQLValueString($_POST['inicio_inst4'], "text"),
                       
GetSQLValueString($_POST['final_inst4'], "text"),
                       
GetSQLValueString($_POST['titulo4'], "text"),
                       
GetSQLValueString($_POST['instituto5'], "text"),
                       
GetSQLValueString($_POST['dir_instituto5'], "text"),
                       
GetSQLValueString($_POST['anos_cur5'], "text"),
                       
GetSQLValueString($_POST['inicio_inst5'], "text"),
                       
GetSQLValueString($_POST['final_inst5'], "text"),
                       
GetSQLValueString($_POST['titulo5'], "text"),
                       
GetSQLValueString($_POST['nomape'], "text"),
                       
GetSQLValueString($_POST['direccion_ref'], "text"),
                       
GetSQLValueString($_POST['tel_ref'], "text"),
                       
GetSQLValueString($_POST['tiempo_ref'], "text"),
                       
GetSQLValueString($_POST['nomape2'], "text"),
                       
GetSQLValueString($_POST['direccion_ref2'], "text"),
                       
GetSQLValueString($_POST['tel_ref2'], "text"),
                       
GetSQLValueString($_POST['tiempo_ref2'], "text"));

  
mysql_select_db($database_pintor$pintor);
  
$Result1 mysql_query($insertSQL$pintor) or die(mysql_error());
}
?>
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #14 (permalink)  
Antiguo 18/03/2008, 07:04
Avatar de hulray  
Fecha de Ingreso: septiembre-2006
Mensajes: 630
Antigüedad: 17 años, 7 meses
Puntos: 3
Re: Enviando campos vacios de form a DB

<?php require_once('../Connections/pintor.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {


disculpa me ignorancia, pero porque 2 "<?php" ????

no te vasta con 1?
  #15 (permalink)  
Antiguo 18/03/2008, 07:13
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Re: Enviando campos vacios de form a DB

si bueno eso es lo de menos... igual elimino uno y m sigue dando el error...

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' , , , 'España', , , , , , , , , , 'cedula', , 'menuitem1', 'Masculino', 'Solte' at line 1
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #16 (permalink)  
Antiguo 18/03/2008, 09:26
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Re: Enviando campos vacios de form a DB

Esta mal generando tu query esa función, prueba cambiar como bien te dijo eft0 por una cadena vacía, no espacio en blanco:
Código PHP:
$theValue = ($theValue != "") ? "'" $theValue "'" "''"
Saludos.
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

SíEste tema le ha gustado a 1 personas




La zona horaria es GMT -6. Ahora son las 15:47.