johngngn 发表于 2015-2-15 17:00:10

关于CI教程create页面插入数据库的问题





为什么我点击Create news item URL会变成
http://test.com/index.php/news/test.com/index.php/news/create?然后显示404

Closer 发表于 2015-2-15 23:37:21

johngngn 发表于 2015-2-15 17:05
按正常应该他要运行else那部分,但是不知道为什么运行不了。
还有那个URL也很诡异。 ...

config 內的 base_url 請設為空

johngngn 发表于 2015-2-15 17:01:32

public function create()
    {
      $this->load->helper('form');
      $this->load->library('form_validation');

      $data['title'] = 'Create a news item';

      $this->form_validation->set_rules('title', 'Title', 'required');
      $this->form_validation->set_rules('text', 'text', 'required');

      if ($this->form_validation->run() === FALSE)
      {
            $this->load->view('templates/header', $data);
            $this->load->view('news/create');
            $this->load->view('templates/footer');

      }
      else
      {
            $this->news_model->set_news();
            $this->load->view('news/success');
      }

    }

这段代码我都照抄的。

johngngn 发表于 2015-2-15 17:05:22

按正常应该他要运行else那部分,但是不知道为什么运行不了。
还有那个URL也很诡异。

johngngn 发表于 2015-2-16 10:01:24

Closer 发表于 2015-2-15 23:37
config 內的 base_url 請設為空

谢谢。已解决!

johngngn 发表于 2015-2-16 10:01:28

Closer 发表于 2015-2-15 23:37
config 內的 base_url 請設為空

谢谢。已解决!
页: [1]
查看完整版本: 关于CI教程create页面插入数据库的问题