Error in prepare () of a query prepared mysqli in PHP

0

Good morning everyone, I have the following function:

function mostrar_producto_carrito($conexion){
    try{
        $sentencia = $conexion->prepare("select p.nombre,c.cantidad,(p.precio*c.cantidad) as total from producto p inner join carrito c on p.id = c.id_producto");
        if($sentencia){
            $sentencia->execute();
            $sentencia=$sentencia->get_result();
            return $sentencia->fetch_all(MYSQLI_ASSOC);        
            $sentencia->close();
            cerrar_conexion($conexion);
        }
    }catch(Exception $e){
        return false;
    }
}

I get the following error:

  

Warning: mysqli :: prepare (): Could not fetch mysqli in C: \ xampp \ htdocs \ virtual-store \ admin \ general \ functions.php on line 155

This is the connection function that passed from the previous function parameter:

function conexion(){
    try{
    $conexion = new mysqli('localhost','root','A6R7u5c6','dbvirtual_store');
    return $conexion;
    }catch(mysqli_sql_exception  $e){
        return false;
    }
}

I hope someone can help me, thanks.

    
asked by U.C 10.08.2018 в 23:59
source

0 answers