Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法通过codeigniter检索要发送的电子邮件数据_Php_Mysql_Codeigniter_Model View Controller_Controller - Fatal编程技术网

Php 无法通过codeigniter检索要发送的电子邮件数据

Php 无法通过codeigniter检索要发送的电子邮件数据,php,mysql,codeigniter,model-view-controller,controller,Php,Mysql,Codeigniter,Model View Controller,Controller,我以前也有过类似的问题,但它已经被修复了,但即使在知道它是如何完成的之后,这仍然是非常令人困惑的。所以我有一个写在控制器上的函数,它从MySQL数据库接收数据,并使用CodeIgniter函数发送电子邮件。这是控制器代码 public function sendEmailToNewBorrower() { //fetch tha data from the database $this->load->model('payment_plan');

我以前也有过类似的问题,但它已经被修复了,但即使在知道它是如何完成的之后,这仍然是非常令人困惑的。所以我有一个写在控制器上的函数,它从MySQL数据库接收数据,并使用CodeIgniter函数发送电子邮件。这是控制器代码

 public function sendEmailToNewBorrower() {
    //fetch tha data from the database 
        $this->load->model('payment_plan');
        $foo = $this->payment_plan->getInfoToNotifyBorrowerForNewLoan();
        $result = json_decode(json_encode($foo), true);

        $this->load->library('email'/*, $config*/);
        $this->email->from('info@loaners.club', 'Loaners CLub');
        $this->email->to($result->Email);
        $this->email->subject('Consumer Credit Information');
        //$msg = $this->load->view('mypayment_view', '', true);
        $name = ($result->Fullname);
        $TotalAmountOfLoan = ($result->capital_payment); 
        $BorrowedAmount = ($result->borrowed_amount);
        $LCcomission = ($result->amount_invoiced);
        $Interest = ($result->interest_payment);
        $Cur = ($result->Abbreviation);
        $duedate = ($result->duedate);
        $installment = ($result->instalmentnbr);
        $BorrowerInterest = ($result->Interest);
        $overdueInterest = ($result->overdue_interest);
        $APR = ($result->total_payment);
        $BorrowingPeriod = ($result->Loantime);
        $msg1 =('https://apps.facebook.com/jussintestins/index.php'); 
        $this->email->message(
            'Hello! '.$name."\n"."\n"
            .'You have  a loan and we would like you to know all information about your loan. '."\n"."\n"."\n"
            .'Loan information'."\n"."\n"

            .'Total Borrowed Amount:  '.$cur.' '.$BorrowedAmount.'.'."\n"
            .'Loaners Club Comission: '.$cur.' '.$LCcomission.'.'."\n"
            .'Total Payment :  '.$cur.' '.$TotalAmountOfLoan.'.'."\n"
            .'Installments :'.$installment.'.'."\n"
            .'Interest Rate :'.$BorrowerInterest.'%.'."\n"
            .'Interest Paid :'.$Interest.'%.'."\n"
            .'Over due payment interest :'.$overdueInterest.'%.'."\n"
            .'Your borrowing period: '.$BorrowingPeriod.'.'."\n"

                ."\n"."\n"
            .'You have the right to withdraw the money'."\n"
            .'You can click this link to pay your loan.'.'Something heere'.'.'."\n"."\n"."\n"
            .'Thank you for using Loaners Club and we would like you to see all our other offers here '.$msg1."\n"."\n"
            .'For more information contact info@loanersclub.com  '
            ."\n"
            ."\n"
            .'Have a great day! Loaners Club'
          );  
    $returnvalue = $this->email->send();
  if(!$returnvalue) {
       alert("email failed to send");
    } else {
     $data=array('notified_borrower'=>current_time,'current_time'=>date('Y-m-d H:i:s'));
     $this->db->update('payment_plan', $data);
       }
}
因此,当我调试程序时,它显示我确实从数据库中获取了数据。 但当我检查$result时,它显示了这一点。

所以现在我不知道为什么会发生这种情况,因为我没有得到存储在那里的信息,但我确实得到一个错误,说不能读取长度。还有一件事是,最后的更新部分也不会更新


我已检查并更正了您的功能。请检查,并记下我留下的评论

public function sendEmailToNewBorrower() {
    //fetch tha data from the database
    $this->load->model('payment_plan');
    $foo = $this->payment_plan->getInfoToNotifyBorrowerForNewLoan();
    /**
     * If @foo is json
     * json_decode($foo); will return an Object. json_decode($foo, true) will return an array
     */
    //$result = json_decode($foo);
    $result = json_decode(json_encode($foo[0]), true);

    $this->load->library('email'/*, $config*/); //Why is the $config off here? make sure you have a proper config loaded for your email library
    $this->email->from('info@loaners.club', 'Loaners CLub');
    $this->email->to($result->Email);
    $this->email->subject('Consumer Credit Information');
    //$msg = $this->load->view('mypayment_view', '', true);
    $name               = $result['Fullname'];
    $TotalAmountOfLoan  = $result['capital_payment'];
    $BorrowedAmount     = $result['borrowed_amount'];
    $LCcomission        = $result['amount_invoiced'];
    $Interest           = $result['interest_payment'];
    $Cur                = $result['Abbreviation'];
    $duedate            = $result['duedate'];
    $installment        = $result['instalmentnbr'];
    $BorrowerInterest   = $result['Interest'];
    $overdueInterest    = $result['overdue_interest'];
    $APR                = $result['total_payment'];
    $BorrowingPeriod    = $result['Loantime'];

    $msg1 =('https://apps.facebook.com/jussintestins/index.php');
    $this->email->message(
        'Hello! '.$name."\n"."\n"
        .'You have  a loan and we would like you to know all information about your loan. '."\n"."\n"."\n"
        .'Loan information'."\n"."\n"
        //You are trying to add a variable named $Cur as $cur. changed it to $Cur..
        .'Total Borrowed Amount:  '.$Cur.' '.$BorrowedAmount.'.'."\n"
        .'Loaners Club Comission: '.$Cur.' '.$LCcomission.'.'."\n"
        .'Total Payment :  '.$Cur.' '.$TotalAmountOfLoan.'.'."\n"
        .'Installments :'.$installment.'.'."\n"
        .'Interest Rate :'.$BorrowerInterest.'%.'."\n"
        .'Interest Paid :'.$Interest.'%.'."\n"
        .'Over due payment interest :'.$overdueInterest.'%.'."\n"
        .'Your borrowing period: '.$BorrowingPeriod.'.'."\n"

        ."\n"."\n"
        .'You have the right to withdraw the money'."\n"
        .'You can click this link to pay your loan.'.'Something heere'.'.'."\n"."\n"."\n"
        .'Thank you for using Loaners Club and we would like you to see all our other offers here '.$msg1."\n"."\n"
        .'For more information contact info@loanersclub.com  '
        ."\n"
        ."\n"
        .'Have a great day! Loaners Club'
    );
    $returnvalue = $this->email->send();
    if(!$returnvalue) {
        alert("email failed to send");
    } else {
        $data=array('notified_borrower'=>current_time,'current_time'=>date('Y-m-d H:i:s'));
        $this->db->update('payment_plan', $data);
    }
}

根据您给定的图像,
$foo
是数组而不是json,因为json\u decode已经给定了数组,所以不需要
json\u decode($foo)您可以直接使用,如下所示

$foo = $this->payment_plan->getInfoToNotifyBorrowerForNewLoan();
$result = json_decode($foo);

在这个函数中,$result=json_decode($foo);结果显示它为空,而foo显示它有数组,所以它仍然不工作。既然它从db返回数组,那么它不应该是($foo,true)对吗?你能在$foo上打印并发布结果吗?请将出现在屏幕顶部的错误作为picture@Farhana你能给我Teamviewer访问权限吗,现在还不清楚onI是怎么做的,但是现在我得到了$name和所有其他带有null的值,并且我得到了这个错误uncaughttypeerror:无法读取未定义的属性'length'(10:41:23:735 | error,javascript)您好,您需要添加$result[0]->Fullname$所有位置的结果[0]?