Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/08/2011, 01:02
elcapitolio
 
Fecha de Ingreso: mayo-2011
Mensajes: 167
Antigüedad: 13 años
Puntos: 1
si no es entero no funciona el script

Les muestro el codigo que tengo...
todo funciona bien cuando
$_POST['descripcion'] = 4; // a un numero
pero si
$_POST['descripcion'] = "Texto y no numero"; // me marca error

asi
Unknown column 'asd' in 'field list'

Código PHP:
Ver original
  1. $cotizacion_no=$row_cotizaid['id']+1;
  2. $sub=array_sum($_POST['precio']);
  3. $total=$sub*1.16;
  4. $iva=$total-$sub;
  5. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  6.   $insertSQL = sprintf("INSERT INTO cotizacion (nombre, fecha, email, razon_social, factura_a, telefono, cotizacion, subtotal, iva, total) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
  7.                        GetSQLValueString($_POST['nombre'], "text"),
  8.                        GetSQLValueString($_POST['fecha'], "date"),
  9.                        GetSQLValueString($_POST['email'], "text"),
  10.                        GetSQLValueString($_POST['razon_social'], "text"),
  11.                        GetSQLValueString($_POST['factura_a'], "text"),
  12.                        GetSQLValueString($_POST['telefono'], "text"),
  13.                        GetSQLValueString($cotizacion_no, "text"),
  14.                        GetSQLValueString($sub, "text"),
  15.                        GetSQLValueString($iva, "text"),
  16.                        GetSQLValueString($total, "text"));
  17.  
  18. $cantidad=$_POST['cantidad'];
  19. $descripcion=$_POST['descripcion'];
  20. $precio=$_POST['precio'];
  21.  
  22. $result = count($_POST['cantidad'])-1;
  23. $i = 0;
  24. while($i <= $result) {
  25.  
  26. $sql2="INSERT INTO cotizacion_detail VALUES (NULL, $cantidad[$i], $descripcion[$i], $precio[$i], $cotizacion_no);";
  27. mysql_select_db($database_noticias, $noticias);
  28.   $Result2 = mysql_query($sql2, $noticias) or die(mysql_error());
  29.  
  30.   ++$i; // Esta instrucción hace que el valor de $i se incremente en 1
  31. }
  32.  
  33.   mysql_select_db($database_noticias, $noticias);
  34.   $Result1 = mysql_query($insertSQL, $noticias) or die(mysql_error());
  35. }