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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.