codeigniter

时间:2016-06-07 11:25:47

标签: php codeigniter

我的型号代码:

public function get_news($id)
{

    $this->db->select('*');     
    $this->db->limit(1);        
    $this->db->order_by("id", "desc");
    $this->db->from('news_article');
    $this->db->where('news_article.submenuid', $id);
    $query = $this->db->get();
    $result=$query->result();
    if($result)
    {
        return $result;
    }
    else
    {

        return false;
    }
}

我的控制器代码是:

public function get_single_news($id)
{   

    $data=array();
    $data['single']=$this->Syllabus_model->get_news($id);
    var_dump($data['single']);                                  
    $data['maincontent']=$this->load->view('single_news/get_single_news', $data, true);
    $this->load->view('welcome_message',$data);   
}

我的观看代码是:

<?php

if(!empty($single){
    forech($single as $values){

        ?>
        <?php $values->id;?>

        <?php
    }
}
else
{
    echo "Have Not Data;
}

?>

数据由var_dump($ data ['single']);

进入控制器

array(1){[0] =&gt; object(stdClass)#31(19){[“id”] =&gt; string(1)“3”[“Title_B”] =&gt; string(35)“ঈমাননওার”[“Title_E”] =&gt; string(35)“ঈমাননওার”[“Title_A”] =&gt; string(35)“ঈমাননওার”[“short_D_B”] =&gt; string(35)“ঈমাননওার”[“short_D_E”] =&gt; string(35)“ঈমাননওার”[“short_D_A”] =&gt; string(35)“ঈমাননওার”[“long_D_B”] =&gt; string(42)“

ঈমাননওার “[”long_D_E“] =&gt;字符串(42)”

ঈমাননওার “[”long_D_A“] =&gt;字符串(42)”

ঈমাননওার “[”imageurl“] =&gt; string(30)”./ upload / 965757556a5a33d79.jpg“[”slideimage“] =&gt; string(3)”YES“[”imagegallary“] =&gt; string(3)”是“[”titilerecent“] =&gt;字符串(3)”是“[”createdate“] =&gt;字符串(19)”2016-06-06 18:19:38“[”userid“] =&gt;字符串(1)“1”[“status”] =&gt; string(1)“0”[“menuid”] =&gt; string(1)“1”[“submenuid”] =&gt; string(3)“120 “}}

错误消息

致命错误:未捕获的TypeError:传递给CI_Exceptions :: show_exception()的参数1必须是Exception的实例,给出ParseError的实例,在C:\ xampp \ htdocs \ tale23 \ tale23 \ system \ core \ Common中调用。 php在第658行并在C:\ xampp \ htdocs \ tale23 \ tale23 \ system \ core \ Exceptions.php中定义:190堆栈跟踪:#0 C:\ xampp \ htdocs \ tale23 \ tale23 \ system \ core \ Common.php (658):CI_Exceptions-&gt; show_exception(Object(ParseError))#1 [内部函数]:_ exception_handler(Object(ParseError))#2 {main}抛出C:\ xampp \ htdocs \ tale23 \ tale23 \ system \ core第190行的Exceptions.php 遇到PHP错误

严重性:错误

消息:未捕获的TypeError:传递给CI_Exceptions :: show_exception()的参数1必须是Exception的实例,给出ParseError的实例,在C:\ xampp \ htdocs \ tale23 \ tale23 \ system \ core \ Common.php中调用在第658行并在C:\ xampp \ htdocs \ tale23 \ tale23 \ system \ core \ Exceptions.php中定义:190堆栈跟踪:#0 C:\ xampp \ htdocs \ tale23 \ tale23 \ system \ core \ Common.php( 658):CI_Exceptions-&gt; show_exception(Object(ParseError))#1 [内部函数]:_ exception_handler(Object(ParseError))#2 {main}抛出

文件名:core / Exceptions.php

行号:190

回溯:

请帮帮我

1 个答案:

答案 0 :(得分:0)

尝试评论或删除var_dump$data['maincontent']行,如下所示:

//var_dump($data['single']); 
//$data['maincontent']=$this->load->view('single_news/get_single_news', $data, true);

我不认为加载视图并将其传递给视图是正确的。