简体   繁体   中英

mysqli num_rows returning zero

i'm new to mysqli trying to select everything from a table but num_rows function is returning 0 what am i doing wrong?

here is my code

    <?php $conn = new mysqli('localhost', 'root', '', 'paa');
    $sql='SELECT * FROM utilisateurs';
    $rs=$conn->query($sql);
    if($rs === false) {
    trigger_error('Wrong SQL: '.$sql.'Error:'.$conn>error,E_USER_ERROR);
      } else {
      $rows_returned = $rs->num_rows;
      echo $rows_returned;
      }

   ?>

Apart from the $conn>error,E_USER_ERROR which should be $conn->error,E_USER_ERROR there is no error in your code. Maybe the table is empty?

This function returns the number of rows found by the query. 0 means that your query returned no rows.

The question why did it so is neither on topic not have any means to be answered.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM