Error in mysqli prepared query in PHP

1

Good day to the community. I have the following function:

function insertar_producto_carrito($id_producto,$cantidad,$conexion){
    try{
        $sentencia = $conexion->prepare("insert into carrito(id_producto,cantidad)values(?,?)");
        if($sentencia){
            $sentencia->bind_param("ii",$id_producto,$cantidad);
            $sentencia->excecute();
            $sentencia->close();
            cerrar_conexion($conexion);
        }
    }catch(Exception $e){
        return false;
    }
}

and when calling it I get the following error:

Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::excecute() in C:\xampp\htdocs\tienda-virtual\admin\general\funciones.php:132 Stack trace: #0 C:\xampp\htdocs\tienda-virtual\admin\ajax\carrito.php(7): insertar_producto_carrito('1', 1, Object(mysqli)) #1 {main} thrown in C:\xampp\htdocs\tienda-virtual\admin\general\funciones.php on line 132

and check the parameters of the method and everything works perfectly, the truth and I did everything that is within my reach without success, if someone has an idea that it can be, I would appreciate it very much, thanks

    
asked by U.C 10.08.2018 в 22:27
source

1 answer

2

You have a syntax error:

should write:

$sentencia->execute(); // OK
// $sentencia->excecute(); // esto tienes tú
    
answered by 10.08.2018 / 22:39
source