homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

mysqli result boolean given ?.huh

5+ Year Member

Msg#: 3704291 posted 8:45 pm on Jul 20, 2008 (gmt 0)


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..



5+ Year Member

Msg#: 3704291 posted 12:59 pm on Jul 22, 2008 (gmt 0)

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:


5+ Year Member

Msg#: 3704291 posted 2:49 pm on Jul 22, 2008 (gmt 0)

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...]


5+ Year Member

Msg#: 3704291 posted 3:04 pm on Jul 22, 2008 (gmt 0)

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.


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

Msg#: 3704291 posted 4:45 am on Jul 23, 2008 (gmt 0)

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.


5+ Year Member

Msg#: 3704291 posted 8:17 am on Jul 23, 2008 (gmt 0)

ok i see....thank you.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved