Welcome to WebmasterWorld Guest from 54.145.53.251

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

mysqli result boolean given ?.huh

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

Junior Member

10+ Year Member

joined:Jan 3, 2005
posts: 187
votes: 0


Hello,

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;
$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 July 22, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:Aug 7, 2007
posts:103
votes: 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:
[fi2.php.net...]
[fi2.php.net...]
2:49 pm on July 22, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:Feb 22, 2008
posts:43
votes: 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...]

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

Junior Member

10+ Year Member

joined:Jan 3, 2005
posts: 187
votes: 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.
4:45 am on July 23, 2008 (gmt 0)

Senior Member

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

joined:Nov 12, 2005
posts:5966
votes: 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.
8:17 am on July 23, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 3, 2005
posts: 187
votes: 0


ok i see....thank you.