为什么这个脚本不起作用?

时间:2011-10-07 17:41:55

标签: php kohana

  

可能重复:
  Why do I get error : Undefined variable?

当我提交名称时,此脚本不会将数据发送到数据库。为什么呢?

这是我的控制器:

class Controller_About extends Controller_Template{
    public function action_index()
    {
        if(!empty($_POST['name'])){
            $name = Model::factory('index')->insert_names($_POST['name']);;
            $result= $name;

        $this->template->site_name = Kohana::$config->load('common')->get('site_name');
        $this->template->site_description = Kohana::$config->load('common')->get('site_description');
        $this->template->page_title = 'About';
        $this->template->content = View::factory('about/about')->set('result', $result);
        $this->template->styles[] = 'index/index';
    }}
}

1 个答案:

答案 0 :(得分:2)

此问题与Why do I get error : Undefined variable?重复,但无论如何我都会回答:您忘了 - >执行()。 Read the docs