• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP Fatal error: Call to a member function num_rows() on boolean

#1
PHP Code:
public function count_all_results($table ''$reset TRUE)
{
if (
$table !== '')
{
$this->_track_aliases($table);
$this->from($table);
}

$result = ($this->qb_distinct === TRUE)
$this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results")
$this->query($this->_compile_select($this->_count_string.$this->protect_identifiers('numrows')));

if (
$reset === TRUE)
{
$this->_reset_select();
}

if (
$result->num_rows() === 0// the error is on this line
{
return 
0;
}

$row $result->row();
return (int) 
$row->numrows;




// I have searched for a solution but nothing so far
Reply

#2
Reduce the number of equal to sign to two instead of 3.
change 
if ($result->num_rows() === 0

to:

if ($result->num_rows() == 0

Boolen 0 is false and 1 is true. 


 
Reply

#3
(04-04-2017, 08:52 AM)koficypher Wrote: Reduce the number of equal to sign to two instead of 3.
change 
if ($result->num_rows() === 0

to:

if ($result->num_rows() == 0

Boolen 0 is false and 1 is true. 


 

This won't change anything.

It's not the num_rows() return value that's the problem.
It's that $result is not an object at all, meaning that the query errored.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.