CodeIgniter Forums

Full Version: mysqli num rows blows up the script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
What is wrong with the below code. It fails on the num_rows, but gives no error message.. it just doesn't go beyond that point. This isn't actually codeignitor code, it's just straight PHP.
if($q = $mysqli->query($sql)) {
      //if($q->num_rows == 0)
       // echo "no rows!";
       fputs($file,"query has completed!".PHP_EOL);
       /* fetch associative array */
       $countRows = $q->num_rows(); // <== won't go past this
       fputs($file,"rows returned: ".$countRows.PHP_EOL);
mysqli_result::$num_rows is a property, not a method.

You've used it correctly on the second line (but commented it out).