send reply message by thread id in buddypress

Get thread id for existing conversation for users or not create new conversation,

  $threadId = buddydev_get_threads_between_users($sender_id, $recip_id );

    if(empty($threadId)){
       if ( $thread_id = messages_new_message( array('sender_id' => $sender_id, 'subject' => $subject, 'content' => $message, 'recipients' => $recip_id ) ) ) {
        bp_core_add_message( __('Message was sent.', 'buddypress' ) );
        } else {
        bp_core_add_message( __( 'There was an error sending Message.', 'buddypress' ), 'error' );
        }
    }
    else{
      if ( messages_new_message( array('sender_id' => $sender_id, 'thread_id' => $threadId[0], 'subject' => $subject, 'content' => $message, 'recipients' => $recip_id ) ) ) {
        bp_core_add_message( __('Message was sent.', 'buddypress' ) );
        bp_core_redirect( $bp->displayed_user->domain ); // adjust as needed
        } else {
        bp_core_add_message( __( 'There was an error sending Message.', 'buddypress' ), 'error' );
        }
    }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)