Error mysqli_fetch_array() expects Parameter 1 to be mysqli_result, bool Given

Asked

Viewed 1,182 times

-1

I’m having a problem with these mistakes:

Warning: mysqli_fetch_array() expects Parameter 1 to be mysqli_result, bool Given in C: xampp htdocs hpveiculos index.php on line 512

Warning: mysqli_fetch_array() expects Parameter 1 to be mysqli_result, bool Given in C: xampp htdocs hpveiculos index.php on line 516

Warning: mysqli_fetch_array() expects Parameter 1 to be mysqli_result, bool Given in C: xampp htdocs hpveiculos index.php on line 526

Code:

<?php
$filtros="";
if (isset($_GET['filtro_cat'])){
    if ($_GET['filtro_cat']!=''){
        $filtros="&& cat='".$_GET['filtro_cat']."'";

                $qr=mysqli_query($conn, "SELECT SUM(valor) as total FROM movimentos WHERE tipo=1 && mes='$mes_hoje' && ano='$ano_hoje' $filtros");
                $row=mysqli_fetch_array($qr);
                $entradas=$row['total'];

                $qr=mysqli_query($conn, "SELECT SUM(valor) as total FROM movimentos WHERE tipo=0 && mes='$mes_hoje' && ano='$ano_hoje' $filtros");
                $row=mysqli_fetch_array($qr);
                $saidas=$row['total'];

                $resultado_mes=$entradas-$saidas;

        }
}

$qr=mysqli_query($conn, "SELECT * FROM movimentos WHERE mes='$mes_hoje' && ano='$ano_hoje' $filtros ORDER By dia");
$cont=0;
while ($row=mysqli_fetch_array($qr)) {
$cont++;

$cat = $row['categoria_id'];
$qr2=mysqli_query($conn, "SELECT nome FROM categorias WHERE id='$cat'");
$row2=mysqli_fetch_array($qr2);
$categoria=$row2['nome'];

?>

1 answer

0

Like the guys said. This error happens because your SQL is wrong, it tries to give a checked variable $filters.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.