Rumah  >  Artikel  >  pembangunan bahagian belakang  >  关于CI教程create页面插入数据库的问题

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

WBOY
WBOYasal
2016-06-06 20:37:541095semak imbas

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

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

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

教程地址(http://codeigniter.org.cn/user_guide/tutorial/create_news_items.html)
为什么我点击Create news item URL会变成
http://test.com/index.php/news/test.com/index.php/news/create?然后显示404

<code>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');
    }

}
</code>

这段代码我都是照抄的。

按正常应该他要运行else那部分,但是不知道为什么运行不了。
还有那个URL也很诡异。
如果他if判断语句成立应该也是load那个view模板,也就是原本这个页面吧?
为什么他会在URL后面直接追加一段URL?

在config/config.php里面将$config['base_url']设置为空已解决了。

回复内容:

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

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

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

教程地址(http://codeigniter.org.cn/user_guide/tutorial/create_news_items.html)
为什么我点击Create news item URL会变成
http://test.com/index.php/news/test.com/index.php/news/create?然后显示404

<code>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');
    }

}
</code>

这段代码我都是照抄的。

按正常应该他要运行else那部分,但是不知道为什么运行不了。
还有那个URL也很诡异。
如果他if判断语句成立应该也是load那个view模板,也就是原本这个页面吧?
为什么他会在URL后面直接追加一段URL?

在config/config.php里面将$config['base_url']设置为空已解决了。

看看你的代码里有没有什么重定向之类的东西!

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn