Skip to main content
Tweeted twitter.com/#!/StackDrupal/status/422297876367413248
Rollback to Revision 3
Source Link
Clive
  • 167.9k
  • 19
  • 303
  • 337

This is the actual function

function uc_guest_checkout_uc_checkout_complete($order, $account) {
  if (!empty($_SESSION['uc_guest_checkout'])  && !user_is_logged_in()) {
    switch ($order->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->uid);
       
        db_query('UPDATE {users} SET name = :name, mail = :mail WHERE uid = :uid',
                array(':name' => $name, ':mail' => $mail, ':uid' => $account->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->data['complete_sale'] = 'new_user';
        break;
    }
  }
  _uc_guest_checkout_end();
}

How can i resolve the query of above one in order to avoid the error. Any suggestions w.r.t query will be nice.Thanks in advance.

This is the actual function

function uc_guest_checkout_uc_checkout_complete($order, $account) {
  if (!empty($_SESSION['uc_guest_checkout'])  && !user_is_logged_in()) {
    switch ($order->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->uid);
       
        db_query('UPDATE {users} SET name = :name, mail = :mail WHERE uid = :uid',
                array(':name' => $name, ':mail' => $mail, ':uid' => $account->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->data['complete_sale'] = 'new_user';
        break;
    }
  }
  _uc_guest_checkout_end();
}

How can i resolve the query of above one in order to avoid the error. Any suggestions w.r.t query will be nice.Thanks in advance.

How can i resolve the query of above one in order to avoid the error. Any suggestions w.r.t query will be nice.Thanks in advance.

added 1206 characters in body
Source Link
Ram
  • 1.3k
  • 15
  • 37

This is the actual function

function uc_guest_checkout_uc_checkout_complete($order, $account) {
  if (!empty($_SESSION['uc_guest_checkout'])  && !user_is_logged_in()) {
    switch ($order->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->uid);
       
        db_query('UPDATE {users} SET name = :name, mail = :mail WHERE uid = :uid',
                array(':name' => $name, ':mail' => $mail, ':uid' => $account->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->data['complete_sale'] = 'new_user';
        break;
    }
  }
  _uc_guest_checkout_end();
}

How can i resolve the query of above one in order to avoid the error. Any suggestions w.r.t query will be nice.Thanks in advance.

How can i resolve the query of above one in order to avoid the error. Any suggestions w.r.t query will be nice.Thanks in advance.

This is the actual function

function uc_guest_checkout_uc_checkout_complete($order, $account) {
  if (!empty($_SESSION['uc_guest_checkout'])  && !user_is_logged_in()) {
    switch ($order->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->uid);
       
        db_query('UPDATE {users} SET name = :name, mail = :mail WHERE uid = :uid',
                array(':name' => $name, ':mail' => $mail, ':uid' => $account->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->data['complete_sale'] = 'new_user';
        break;
    }
  }
  _uc_guest_checkout_end();
}

How can i resolve the query of above one in order to avoid the error. Any suggestions w.r.t query will be nice.Thanks in advance.

deleted 75 characters in body
Source Link
Ram
  • 1.3k
  • 15
  • 37

I am using ubercart guest checkout module. I am able to submit the order as guest etc works fine.

After Reviewing the order and submitting it throws me this error

Recoverable fatal error: Argument 2 passed to db_query() must be an array,
string given, called in
/var/www/html/dev.demo.net/sites/all/modules/ubercart_guest_checkout/uc_guest_checkout.module
on line 263 and defined in db_query() (line 2342 of
/var/www/html/dev.demo.net/includes/database/database.inc).

This is the query which is causing that issue

db_query('UPDATE {users} SET name = "%s", mail = "%s" WHERE uid = %d', $name, $mail, $account->uid);

I tried to change this query like this

db_update('users')
        ->fields(array(
            'name' => $name,
            'mail' => $mail,
            'uid' => $account->uid,         
        ))
        ->condition('uid','0'$account->uid,'<>''=')       
        ->execute();

still no luck, it throws me this specificsame above specified error.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '242' for key 'PRIMARY': UPDATE {users} SET name=:db_update_placeholder_0, mail=:db_update_placeholder_1, uid=:db_update_placeholder_2 WHERE (uid <> :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] => anon-52ccdb803da735.60518875 [:db_update_placeholder_1] => [email protected] [:db_update_placeholder_2] => 242 [:db_condition_placeholder_0] => 0 ) in uc_guest_checkout_uc_checkout_complete() (line 271 of /sites/all/modules/ubercart_guest_checkout/uc_guest_checkout.module).

How can i resolve the query of above one in order to avoid the error. Any suggestions w.r.t query will be nice.Thanks in advance.

I am using ubercart guest checkout module. I am able to submit the order as guest etc works fine.

After Reviewing the order and submitting it throws me this error

Recoverable fatal error: Argument 2 passed to db_query() must be an array,
string given, called in
/var/www/html/dev.demo.net/sites/all/modules/ubercart_guest_checkout/uc_guest_checkout.module
on line 263 and defined in db_query() (line 2342 of
/var/www/html/dev.demo.net/includes/database/database.inc).

This is the query which is causing that issue

db_query('UPDATE {users} SET name = "%s", mail = "%s" WHERE uid = %d', $name, $mail, $account->uid);

I tried to change this query like this

db_update('users')
        ->fields(array(
            'name' => $name,
            'mail' => $mail,
            'uid' => $account->uid,         
        ))
        ->condition('uid','0','<>')       
        ->execute();

still no luck, it throws me this specific error

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '242' for key 'PRIMARY': UPDATE {users} SET name=:db_update_placeholder_0, mail=:db_update_placeholder_1, uid=:db_update_placeholder_2 WHERE (uid <> :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] => anon-52ccdb803da735.60518875 [:db_update_placeholder_1] => [email protected] [:db_update_placeholder_2] => 242 [:db_condition_placeholder_0] => 0 ) in uc_guest_checkout_uc_checkout_complete() (line 271 of /sites/all/modules/ubercart_guest_checkout/uc_guest_checkout.module).

How can i resolve the query of above one in order to avoid the error. Any suggestions w.r.t query will be nice.Thanks in advance.

I am using ubercart guest checkout module. I am able to submit the order as guest etc works fine.

After Reviewing the order and submitting it throws me this error

Recoverable fatal error: Argument 2 passed to db_query() must be an array,
string given, called in
/var/www/html/dev.demo.net/sites/all/modules/ubercart_guest_checkout/uc_guest_checkout.module
on line 263 and defined in db_query() (line 2342 of
/var/www/html/dev.demo.net/includes/database/database.inc).

This is the query which is causing that issue

db_query('UPDATE {users} SET name = "%s", mail = "%s" WHERE uid = %d', $name, $mail, $account->uid);

I tried to change this query like this

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

still no luck, it throws me same above specified error.

How can i resolve the query of above one in order to avoid the error. Any suggestions w.r.t query will be nice.Thanks in advance.

added 514 characters in body; edited title
Source Link
Ram
  • 1.3k
  • 15
  • 37
Loading
Source Link
Ram
  • 1.3k
  • 15
  • 37
Loading