dongzhong8691 2012-10-11 06:22
浏览 28

加载管理员email()codeigniter。

I was trying to find out the error but I coudnt. I use codeigniter. Here is the code

function send_emailalertstoAdmin($emailmessage,$ad_title)
{
     $this->load->model('user_model');
     $query_result =  $this->user_model->load_administrator_email();

    //$this->load->database();

    //$query = $this->db->query('SELECT users.email FROM users WHERE users.id =1');

    foreach ($query_result as $row)
    {           
        $email= $row->email;

        $successmasg = '';
        $from = "info@xxxt.com";                    
        $subject = "xxx ". $ad_title . " is Stolen"; 
        $message = $emailmessage;
        $headers  = 'MIME-Version: 1.0' . "
";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
        $headers .= 'From: xxxxx.com <info@xxxxt.com>' . "
"; 

        $successmasg = mail($email, $subject, $message, $headers);
    }
}

I got the following error. Fatal error: Call to undefined method User_model::load_administrator_email()

Here is the load_administrator_email() function

function load_administrator_email()
{
    $sql = "SELECT users.email FROM users WHERE users.id =1";
    $queryData = $this-> db->query($sql);   
    return $queryData -> result();
}   

I was trying to find the error but I coudnt. what I tried, 1. sql query is correct and it gives correct result. 2. when I hardcode email and comment calling load_administrator_email() in first function ,email goes correctly.

please help me to correct this.

thx in advance

  • 写回答

1条回答 默认 最新

  • dongyi1524 2012-10-11 08:29
    关注

    Load your model like this..

    $this->load->model('user_model', '', TRUE);
    

    Or else load it in the constructor

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!