Call to undefined function mysqli_result::num_rows()

From the manual, it seems that mysqli_result::num_rows isn’t a function, but rather a variable containing the number of rows.

It can be used like this:

$num_rows = $mysqli_result->num_rows;

The function equivalent is mysqli_num_rows($result), where you pass in the mysqli_result object, but that’s if you’re using the procedural style rather than object oriented style.

In your code, you should change your count() function in the utils_MysqlImprovedResult class to be like this (I’m assuming that’s the function where you’re getting the error message),

public function count()
{
    // Any other processing you want
    // ...
    return $this->_result->num_rows;
}

or alternatively if you want to mix OO and procedural styles (probably a bad idea),

public function count()
{
    // Any other processing you want
    // ...
    return mysqli_num_rows($this->_result);
}

Leave a Comment