boolean query problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
set321go
Forum Newbie
Posts: 2
Joined: Tue Jun 08, 2010 9:40 am

boolean query problem

Post by set321go »

hello,

if i run my query i get this error

Code: Select all

Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given in ...... line 41
am i correct in thinking this is because it thinks there are no results?

this is the query code where last line is line 41

Code: Select all

        $query2 = "SELECT remove_client, add_new, modify_client, view_client".
                 "FROM roles".
                 "WHERE rid=".
                     "(SELECT rid".
                      "FROM login".
                       "WHERE uid= ".$_SESSION['user_id'].")";
        $results = mysqli_query($dbc, $query2);
        $row_vals =  mysqli_fetch_row($results);
the values returned from the database are boolean values.
when i run this query

Code: Select all

SELECT remove_client, add_new, modify_client, view_client
FROM roles
WHERE rid = ( 
SELECT rid
FROM login
WHERE uid =1 ) 
i get one row as expected.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: boolean query problem

Post by AbraCadaver »

Code: Select all

echo $query2;
I bet it looks like this:
[text]SELECT remove_client, add_new, modify_client, view_clientFROM rolesWHERE rid=(SELECT ridFROM loginWHERE uid=1)[/text]

You can also do this to get the error:

Code: Select all

$results = mysqli_query($dbc, $query2) or die(mysqli_error($dbc));
Last edited by AbraCadaver on Tue Jun 08, 2010 10:22 am, edited 2 times in total.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
set321go
Forum Newbie
Posts: 2
Joined: Tue Jun 08, 2010 9:40 am

Re: boolean query problem

Post by set321go »

thanks you were spot on, there were no gaps
User avatar
phdatabase
Forum Commoner
Posts: 83
Joined: Fri May 28, 2010 10:02 am
Location: Fort Myers, FL

Re: boolean query problem

Post by phdatabase »

It's also nice to know what your calls return and under what conditions... http://us2.php.net/manual/en/mysqli.query.php
Post Reply