Ver Mensaje Individual
  #11 (permalink)  
Antiguo 06/07/2015, 09:03
pandora09
 
Fecha de Ingreso: julio-2015
Mensajes: 16
Antigüedad: 8 años, 10 meses
Puntos: 1
Respuesta: Problemas con Insert de id en tabla factura_detalle

chronos682, he hecho lo que me dijiste quedando esa linea de codigo de esta manera:

Código PHP:
Ver original
  1. $resul= mysql_query($sql1) or die ();

Y ahora no me arroja el mensaje de error de conexión con la tabla factura_detalle pero la pagina se queda en blanco y sigue sin insertarme esos datos.

Es decir, queda igual pero sin el mensaje. Este es mi codigo completo:

Código PHP:
Ver original
  1. <?
  2. //Declarando Variables
  3.  $cedula=$_POST['cedula'];
  4.  $fecha=$_POST['fecha'];
  5.  $hora=$_POST['hora'];
  6.  $codigo=$_POST['codigo'];
  7.  $forma_pago=$_POST['forma_p'];
  8.  $total=$_POST['total'];
  9.  $accion=$_POST['accion'];
  10.  $servicio= array();
  11.  $cantidad= array();
  12.  $preciounit= array();
  13.  $totalitem=array();
  14.  
  15. foreach($_POST['servicio'] as $key=>$value)
  16.     $servicio[]= $value;
  17.  
  18. foreach($_POST['cantidad'] as $key=>$value)
  19.     $cantidad[]= $value;
  20.  
  21. foreach($_POST['preciounit'] as $key=>$value)
  22.     $preciounit[]= $value;
  23.  
  24. foreach($_POST['totalitem'] as $key=>$value)
  25.     $totalitem[]= $value;
  26.  //SI SE PULSA EL BOTON REGISTRAR FACTURA
  27.  if ($_POST[Registrar_Factura]) {
  28.  include('conexionbd.php');
  29.  $hora=gmdate('H:i:s', time() - 16200);
  30.  
  31.  //INGRESO LA CABECERA DE LA FACTURA
  32.  $sql="INSERT INTO factura_datos (cedula,fecha,hora,forma_p,total) VALUES
  33.       ('".$cedula."','".$fecha."','".$hora."','".$forma_pago."','".$total."')";
  34.  $result=mysql_query($sql) or die ("Error en la Conexión a la Tabla Factura_Datos");
  35.  
  36.  //SELECCIONO EL ULTIMO ID INGRESADO DE LA TABLA FACTURA_DATOS
  37.  $ultimo_id=mysql_insert_id();
  38.  
  39.  //RECORRO LOS ARRAYS
  40.  for($i=0; $i<count($servicio); $i++)
  41.            {
  42.  
  43.  //INGRESO LOS DATOS EN LA TABLA FACTURA_DETALLE
  44.  $sql1="INSERT INTO factura_detalle (fact_nro,descripcion,cant,precio,sub_t) VALUES
  45.       ('".$ultimo_id."','".$servicio[$i]."','".$cantidad[$i]."','".$preciounit[$i]."','".$totalitem[$i]."')";
  46.  $resul= mysql_query($sql1) or die ();
  47.            }
  48.  ?><script>alert("Factura Registrada con Exito"); document.location = 'facturacion.php';</script><?
  49.  }
  50. ?>