Welcome Guest, Not a member yet? Register   Sign In
Get value from the query and put on controller for sending MAIL
#1

[eluser]fnbhns[/eluser]
Dear All,

First of all appologise for my english. I am new in codeigniter. I want to select email address each time 1 from DB table and want to sent mail in that mailing address. Looking for your help and support.

This is my CONTROLLER :
Code:
public function index() {

$user_id = $this->check_model->vehicleUserId($cus_info['id']);
$mailData = array();
$mailData['from_address'] = "[email protected]";
$mailData['admin_full_name'] = "GEO Science";
$mailData["to_address1"] =$this->db
                   ->select('user_email')
                   ->where('user_info_id',$user_id)
                   ->get('user_info')
                   ->row();

$this->check_out_model->sendReservationEmail($mailData, 'vehicle_booking_email_view');
          
          }


This is my MODEL bellow

Code:
public function sendReservationEmail($data,$templateName){
$this->load->library('email');
            $this->email->set_mailtype('html');
            $this->email->from($data['from_address'],$data['admin_full_name']);
            $this->email->to($data['to_address1']);
            $this->email->subject($data['subject']);
            $body = $this->load->view('mailScripts/' . $templateName, $data, true);
            $this->email->message($body);
            $this->email->send();
            $this->email->clear();
            
    
        
    }
[u]Showing some error.[/u]

Quote:A PHP Error was encountered
Severity: Warning
Message: strpos() expects parameter 1 to be string, object given
Filename: libraries/Email.php
Line Number: 444

Even its showing that, the email address received from DB. Can not convert in STRING.I am trying my level best. but i think i need your help. I am highly expecting your support. Thank you so much in advance.
#2

[eluser]Tpojka[/eluser]
Seems like you forgot $user_id as argument passed in index() method?
#3

[eluser]fnbhns[/eluser]
Thank you for your quick reply. I did little mistake But the User_id is there. using these User_id i am picking the email address from the table. But when i am using $this->email->to($data['to_address1']); its showing a message that EMAIL address can not be converted as string. So the mail is not sending. If you have any idea please i got really tired ................!!
#4

[eluser]InsiteFX[/eluser]
Code:
->row();

// Should be
->row_array();

result and row are objects - result_array and row_array are associated arrays.
#5

[eluser]fnbhns[/eluser]
Thank you all, my problem is been solved. Special thanks to
Quote:InsiteFX
. Your comments became so helpful.




Theme © iAndrew 2016 - Forum software by © MyBB