Page 1 of 1

boolean query problem

Posted: Tue Jun 08, 2010 9:50 am
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.

Re: boolean query problem

Posted: Tue Jun 08, 2010 9:53 am
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));

Re: boolean query problem

Posted: Tue Jun 08, 2010 9:59 am
by set321go
thanks you were spot on, there were no gaps

Re: boolean query problem

Posted: Tue Jun 08, 2010 10:02 am
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