Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

mysqli result boolean given ?.huh



8:45 pm on Jul 20, 2008 (gmt 0)

10+ Year Member


Im getting the following error in a script..

Error #2: 'mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given' in C:\xampp\htdocs\links\databases\mysqli.php on line 42

line 42 is:
function numrows($q) { return mysqli_num_rows($q); }

The bigger part is:

function query($query)
global $debug, $debuginfo, $querycount;
if ($debug == 1) echo "<p><b>Query $querycount:</b> $query</p>";
else $debuginfo .= "<p><b>Query $querycount:</b> $query</p>";
return mysqli_query($this->dbh, $query);
function error() { return mysqli_error($this->dbh); }
function numrows($q) { return mysqli_num_rows($q); }
function lastid() { return mysqli_insert_id($this->dbh); }
function numfields($result) { return mysqli_num_fields($result); }
function row($result) { return mysqli_fetch_row($result); }
function fieldname($q1, $b) { return $this->fetchcolumn($q1, $b); }
function fieldtype($q1, $b) { $o = mysqli_fetch_field_direct($q1, $b); return typenumbertoname($o->type); }
function fieldlength($q1, $b) { $o = mysqli_fetch_field_direct($q1, $b); return $o->length; }
function fetcharray($result) { return mysqli_fetch_array($result); }
function fetchassoc($result) { return mysqli_fetch_assoc($result); }
function fetchcolumn($result, $column)

can someone please explain what this means ?

Thank you..


12:59 pm on Jul 22, 2008 (gmt 0)

5+ Year Member

Where are you calling the function numrows()?
The error code states that you are sending a boolean to the function and you should be sending a mysql resource. This resource comes from a valid mysql query.
Maybe the sql query you are making is not valid and produces a FALSE boolean and then you are trying to send this boolean to the numrows() function.
I suggest you check out the following on PHP.net:


2:49 pm on Jul 22, 2008 (gmt 0)

5+ Year Member

What is your Query?

mysqli_query(): Returns TRUE on success or FALSE on failure. For SELECT, SHOW, DESCRIBE or EXPLAIN mysqli_query() will return a result object.

If you are useing 'INSERT, UPDATE, DELETE' ect you will get TRUE or FALSE returend depending if it was sucessfull, not a result object.

Read up on it here: [uk3.php.net...]


3:04 pm on Jul 22, 2008 (gmt 0)

10+ Year Member

thanks but its not my script.
i posted the error as i saw it.
was just wondering what the error means....
then hopefully i can understand that.


4:45 am on Jul 23, 2008 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member

It means that wherever you are calling the function numrows($var) the $var isn't a valid argument. It should be the result from mysqli_query. The code that you have given us is correct. You are calling the function numrows somewhere else in your code and that is what is creating the error.


8:17 am on Jul 23, 2008 (gmt 0)

10+ Year Member

ok i see....thank you.

Featured Threads

Hot Threads This Week

Hot Threads This Month