Jump to content

query error


doddsey_65

Recommended Posts

mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean

 

i get that error with this code:

 

$online_query = $link->simple_query('u_username', 'users', 'u_online=1 AND u_hidden != 1', '0u_username');

while($online_info = $link->fetch_array($online_query)) //THIS LINE THROWS THE ERROR

 

the simple_query function is:

 

function simple_query($fields, $table, $clause, $order)
    {
        global $link, $config;
        
        if(!empty($clause))
        {
            $clause = "WHERE $clause";
        }
        else
        {
            $clause = '';
        }    
            
        if(!empty($order))
        {
            $direction = $order[0];
            
            switch($direction)
            {
                case '0':
                $direction = 'ASC"';
                break;
                case '1':
                $direction = 'DESC';
                break;
            }
            
            $order = substr($order, 1, strlen($order));
            $order = "ORDER BY $order $direction";
        }
        
        $query = mysqli_query($this->link, "SELECT $fields
                FROM ".TBL_PREFIX."$table
                $clause
                $order");
        
        return $query;
    }

 

when i use a normal query instead of my simple_query function it works fine. it also worked fine before i made the database class. Where am i going wrong?

Link to comment
https://forums.phpfreaks.com/topic/225402-query-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.