Warning: mysqli_num_rows () expects parameter 1 to be mysqli_result, string given in

0

I can not show the data that the query brings me. I work with mySQL and a model of views and controllers.

I get this error: Warning: mysqli_num_rows () expects parameter 1 to be mysqli_result, string given in . And the variable is not empty.

public function listaTarjetas(){

        $db=BaseDeDatos::conectarBD();

        $sql='select * from tarjetas;';

        $result=mysqli_query($db, $sql);

        return $result;
    }
    
$usuario = new Model_Usuario();

$tarjetas =  $usuario->listaTarjetas();


<?php       if(mysqli_num_rows($data)>0){
                    while($rows=mysqli_fetch_assoc($data)){
                        echo $rows['idTarjetas'];
                    }
                }  ?>
    
asked by Alan Snyder 17.12.2018 в 17:49
source

1 answer

0

A small error in passing the parameter to the function% co_of% that an object expects as a result of the query.

$tarjetas =  $usuario->listaTarjetas();
if(mysqli_num_rows($data)>0){ <----- aquí deberías pasar la variable $tarjetas
    while($rows=mysqli_fetch_assoc($data)){ <----- aquí también
        echo $rows['idTarjetas'];
    }
}
    
answered by 17.12.2018 в 17:55