404 Error On News Tutorial |
Hi Everyone, I am pretty much new to Codeigniter and am working through the news tutorial on the Codeigniter website. I keep getting a 404 error when accessing index.php/news. Specifically, I get the following error:
Quote:load->model('news_model'); $this->load->helper('url_helper'); } public function index() { $data['news'] = $this->news_model->get_news(); $data['title'] = 'News archive'; $this->load->view('templates/header', $data); $this->load->view('templates/footer'); $this->load->view('news/index', $data); } public function view($slug = NULL) { $data['news_item'] = $this->news_model->get_news($slug); if (empty($data['news_item'])) { show_404(); } $data['title'] = $data['news_item']['title']; $this->load->view('templates/header', $data); $this->load->view('news/view', $data); $this->load->view('templates/footer'); } } Below is all of my code. Does anyone have any thoughts? I appreciate any help. Thanks! News_model.php (Model) PHP Code: <?php News.php (controller) PHP Code: <? index.php (View) PHP Code: <h2><?php echo $title; ?></h2> view.php (View) PHP Code: <?php routes.php PHP Code: $route['news/(:any)'] = 'news/view/$1';
You have <? at the start of your News controller. Do you have short tags enabled?
Try changing it to <?php as normal.
That worked perfectly. Thank you!
However, now I am getting another error: An Error Was Encountered Unable to load the requested file: news/index.php I double-checked the controller and the routes file and it looks right to me, compared to the tutorial. Any thoughts? Thanks!
Bump.
Does anyone have any thoughts on this? Or a good recommendation to a website that can help me research these types of problems? Thanks!
Awww shoot. It's always the simple stuff. I put it in views, but not views/news.
Thank you so much!
|
Welcome Guest, Not a member yet? Register Sign In |