Ver Mensaje Individual
  #1  
Antiguo 20-02-2007
analondo analondo is offline
Registrado
 
Registrado: feb 2007
Posts: 6
Reputación: 0
analondo Va por buen camino
Red face Insert y Update al mismo tiempo dentro de php

Buenas, estoy tratando de realizar un update despues de insertar un componente. El codigo es
Código PHP:
if ($_POST['Origen']=="add")
{        
        
$Venta=$_POST['Venta'];
        
$Fecha=$_POST['DateIni'];
        
$Producto=$_POST["Producto"];        
        
$Factura=$_POST["Factura"];
        
$Manguera=$_POST["Manguera"];
        
$Surtidor=$_POST["Surtidor"];
        
$Islero=$_POST['Islero'];        
        
$PPG=$_POST["PPG"];
        
$Cantidad=$_POST["Cantidad"];
        
$Valor=$_POST["Valor"];
        
$Empresa=$_POST['Empresa']; 
        
$Placa=$_POST['Placa'];
        
$Cantidad=$Cantidad*1000;
        
$sth1 ibase_query("SELECT * FROM MANGUERAS where ID_Manguera=$Manguera");
        while (
$row1 ibase_fetch_row($sth1))
            {
                
$Manguera=$row1[0];
                
$Surtidor=$row1[2];
            }

        if((
$Placa!='')and($Empresa!='Panel'))
        {
            
$sth ibase_query("INSERT INTO VENTAS (ID_VENTA,FECHA,PRODUCTO,CANTIDAD,ID_MANGUERA,ID_SURTIDOR,ID_ISLERO,VALOR,EMPRESA,PLACA, NO_FACTURA,PPG,OBSERVACIONES) 
                            VALUES(GEN_ID(GEN_ID_VENTAS,1),'
$Fecha','$Producto','$Cantidad','$Manguera','$Surtidor','$Islero','$Valor','$Empresa','$Placa','$Factura','$PPG','')");
            
ibase_commit();
            
mensage(12345,'commit-');
                            
        }
        else if    ((
$Placa!='')and($Empresa=='Panel'))
        {
            
$sth ibase_query("INSERT INTO VENTAS (ID_VENTA,FECHA,PRODUCTO,CANTIDAD,ID_MANGUERA,ID_SURTIDOR,ID_ISLERO,VALOR,EMPRESA,PLACA, NO_FACTURA,PPG,OBSERVACIONES) 
                            VALUES(GEN_ID(GEN_ID_VENTAS,1),'
$Fecha','$Producto','$Cantidad','$Manguera','$Surtidor','$Islero','$Valor','Panel','P_$Placa','$Factura','$PPG','')");
            
ibase_commit();
            
mensage(12345,'commit-');
        }
        else
        {
            
$sth ibase_query("INSERT INTO VENTAS (ID_VENTA,FECHA,PRODUCTO,CANTIDAD,ID_MANGUERA,ID_SURTIDOR,ID_ISLERO,VALOR,EMPRESA,PLACA, NO_FACTURA,PPG,OBSERVACIONES) 
                            VALUES(GEN_ID(GEN_ID_VENTAS,1),'
$Fecha','$Producto','$Cantidad','$Manguera','$Surtidor','$Islero','$Valor','Personal','','$Factura','$PPG','')");
            
ibase_commit();
            
mensage(12345,'commit-');
        }
        
        
        
$sth2 ibase_query("select PROGRAMA, UNIDADESXPUNTOS, TIPO_PUNTOS from EMPRESAS where ID_EMPRESA=$Empresa");
        while(
$row2 ibase_fetch_row($sth2))
        {
            echo 
"<h1>HOLA!!!</h1>";
            
//Si es Programa de Fidelizacion
            
if($row2[0]==0)
            {
                if(
$row[2]==1)
                    
$puntos=ceil($Valor/$row[1]);
                else
                    
$puntos=ceil($Cantidad/$row[1]);
                
                
$sth3ibase_query("select EMPRESA,PUNTOS from VEHICULOS where PLACA=$Placa");
                while(
$row3 ibase_fetch_row($sth3))
                {    
                    if(
$row3[0]==$Empresa)
                    {
                        
$puntoVeh=$row3[1];
                        
$puntoVeh=$puntoVeh+$puntos;
                        
$sth4=ibase_query("update VEHICULOS set PUNTOS=$puntoVeh where PLACA=$Placa");
                        
ibase_commit();
                    }
                    
                    else
                        echo 
"alert('La Placa del vehiculo no pertenece al plan señalado')";
                    
                }
            }
        
        
        }
        
        

No se que tengo malo que no me funciona, me esta insertando el campo pero no me esta haciendo el query despues, ni siquiera $sth2 = ibase_query("select PROGRAMA, UNIDADESXPUNTOS, TIPO_PUNTOS from EMPRESAS where ID_EMPRESA=$Empresa");. Cualquier ayuda se los agradeceria enormemente

//Editado por jhonny para colocar etiquetas php

Última edición por jhonny fecha: 20-02-2007 a las 17:03:09.
Responder Con Cita