homepage Welcome to WebmasterWorld Guest from 54.211.157.103
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

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
john1000




msg:3703070
 8:45 pm on Jul 20, 2008 (gmt 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..

 

deMorte




msg:3704432
 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:
[fi2.php.net...]
[fi2.php.net...]

mrscruff




msg:3704519
 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...]

john1000




msg:3704530
 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.

eelixduppy




msg:3705058
 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.

john1000




msg:3705139
 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