404 Error On News Tutorial - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: 404 Error On News Tutorial (/showthread.php?tid=63630) |
404 Error On News Tutorial - mpar612 - 11-20-2015 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'; RE: 404 Error On News Tutorial - JayAdra - 11-20-2015 You have <? at the start of your News controller. Do you have short tags enabled? Try changing it to <?php as normal. RE: 404 Error On News Tutorial - mpar612 - 11-21-2015 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! RE: 404 Error On News Tutorial - mpar612 - 11-23-2015 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! RE: 404 Error On News Tutorial - Martin7483 - 11-23-2015 (11-21-2015, 11:22 AM)mpar612 Wrote: Unable to load the requested file: news/index.php Sounds like the view file can't be found. Did you place it in ./application/views/news/index.php RE: 404 Error On News Tutorial - mpar612 - 11-23-2015 Awww shoot. It's always the simple stuff. I put it in views, but not views/news. Thank you so much! RE: 404 Error On News Tutorial - Martin7483 - 11-23-2015 (11-23-2015, 11:26 AM)mpar612 Wrote: Awww shoot. It's always the simple stuff. I put it in views, but not views/news. You're welcome! RE: 404 Error On News Tutorial - rohit176 - 11-24-2015 Awesome! |