How to avoid the error 'array expected string given' in db_query I am getting this error: Argument 2 passed to db_query() must be an array,
string given. In db_query in below function. 

function uc_guest_checkout_uc_checkout_complete($order, $account) {
  if (!empty($_SESSION['uc_guest_checkout'])  &amp;&amp; !user_is_logged_in()) {
    switch ($order-&gt;data['complete_sale']) {
      case 'new_user':
        // For guest checkout, we replace the ubercart generated username and email
        // for a new user with one that is more anonymous.
        $name = uniqid('anon-', TRUE);
        $mail = $name . '.' . uc_store_email();        
        db_query('UPDATE {users} SET name = "%s", mail = "%s" WHERE uid = %d', $name, $mail, $account-&gt;uid);   
   break;
  case 'logged_in':
    // If the order is marked logged in but anonymous, this means that 
    // we must have set the uid to the default account, but still treat
    // this as a new user.
    $order-&gt;data['complete_sale'] = 'new_user';
    break;
    }
  }
  _uc_guest_checkout_end();
}


I tried this queries but none were creating account with valid names and emails as per db_query which is throwing error but successfully creating user accounts.where as these below queries creating names with random names.

db_update('users')
        -&gt;fields(array(
            'name' =&gt; $name,
            'mail' =&gt; $mail
        ))
        -&gt;condition('uid', $account-&gt;uid)       
        -&gt;execute();

db_query('UPDATE {users} SET name = :name, mail = :mail WHERE uid = :uid',
                array(':name' =&gt; $name, ':mail' =&gt; $mail, ':uid' =&gt; $account-&gt;uid));


How do I resolve this?
You're using Drupal 6 syntax, you need to convert it to Drupal 7 syntax:

db_update('users')
  -&gt;fields(array('name' =&gt; $name, 'mail' =&gt; $mail))
  -&gt;condition('uid', $account-&gt;uid)
  -&gt;execute();


See the Database API docs for more details.