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.