关于CI教程create页面插入数据库的问题
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了关于CI教程create页面插入数据库的问题,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1958字,纯文字阅读大概需要3分钟。
内容图文
![关于CI教程create页面插入数据库的问题](/upload/InfoBanner/zyjiaocheng/238/c867286f8c1e4c048ec7f43aa7be3e5f.jpg)
教程地址(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
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');
}
}
这段代码我都是照抄的。
按正常应该他要运行else那部分,但是不知道为什么运行不了。
还有那个URL也很诡异。
如果他if判断语句成立应该也是load那个view模板,也就是原本这个页面吧?
为什么他会在URL后面直接追加一段URL?
在config/config.php里面将$config['base_url']设置为空已解决了。
回复内容:
教程地址(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
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');
}
}
这段代码我都是照抄的。
按正常应该他要运行else那部分,但是不知道为什么运行不了。
还有那个URL也很诡异。
如果他if判断语句成立应该也是load那个view模板,也就是原本这个页面吧?
为什么他会在URL后面直接追加一段URL?
在config/config.php里面将$config['base_url']设置为空已解决了。
看看你的代码里有没有什么重定向之类的东西!
内容总结
以上是互联网集市为您收集整理的关于CI教程create页面插入数据库的问题全部内容,希望文章能够帮你解决关于CI教程create页面插入数据库的问题所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。