fetch_array () error in php7

1

I used this code in php version 5, but after I switched to php 7, this error appeared.

  

Fatal error: Uncaught fetch_array ()   on array

$selec = $mysqli->query("SELECT cpf_cnpj, isento, ... ");
$exec = $selec->fetch_assoc();

while($campos = $exec->fetch_array()) {
    extract($campos);
    $Array = Array(); 

    $Array[] = Array(
                        "cpf_cnpj"  => "$cpf_cnpj",
                        "isento"    => "$isento", 
                    ); 

    $json_encode = json_encode($Array); 
    echo $json_encode; 
}

What am I doing wrong?

Thank you.

    
asked by anonymous 20.02.2018 / 14:05

1 answer

0

Change your code you are doing the fetch () of the times put MYSQLI_ASSOC inside your Fetch_array ()

<?php
$selec = $mysqli->query("SELECT cpf_cnpj, isento, ... ");


while($campos = $selec->fetch_array(MYSQLI_ASSOC)) {



    $json_encode = json_encode($campos); 
    echo $json_encode; 
}
?>
    
20.02.2018 / 14:19