-2

The problem im having is that, mysql num rows will not work unless the users id is 1.

if its anything else it displays this

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/theclear/public_html/redline/class/class_db_mysqli.php on line 66

The part calling for the numb rows:

$rrr=$db->query("SELECT * FROM referals WHERE refREFER={$r['userid']}");
print $db->num_rows($rrr);

and the function from class_db_mysqli.php (incl line 66):

 function num_rows($result=0)
  {
    if(!$result) { $result=$this->result; }
    return mysqli_num_rows($result);
  }

I can't work out why it works fine if userid=1 but not if userid > 1....

as far as i can figure out...

Im -> Id 1 You are -> Id2

$userid=$_GET['u']

if i visit domain.xxx/file.php?u=1

No error and correct results are displayed.

if i visit domain.xxx/file.php?u=2

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/theclear/public_html/redline/class/class_db_mysqli.php on line 66

is displayed

1 Answers1

1

Your warning is not telling you that the id has to be 1. Rather, it is saying that the first argument in mysqli_num_rows() needs to be of type mysqli_result. You are giving a boolean value.

This is because your call to mysqli_query is returning a boolean value of FALSE. Read up on the docs of that function, and you can also find out what the error is with mysqli_error.

Anid Monsur
  • 4,563
  • 1
  • 16
  • 24
  • Then why does it work fine, when userid=1, and not when userid is anything else? – user3147145 Feb 12 '14 at 22:16
  • I wouldn't try to guess. All you have to do is `if ($rrr === false) echo $db->error`. – Anid Monsur Feb 12 '14 at 22:18
  • @ginowa320 i tried that. gave me `Notice: Undefined property: database::$error in /home/theclear/public_html/redline/file.php on line 94` (i added ; to the end if thats the problem?) – user3147145 Feb 12 '14 at 22:23