Beginner : How to debug |
[eluser]Unknown[/eluser]
This is my very first time to try CI. I tried to follow tutsplus video with the following scenarion: Model (post.php): <?php class Post extends CI_Model { function get_posts($num=20, $start=0) { $this->db->select()->from('posts')->where('active',1)->order_by('date_added', 'desc')->limit($num,$start); $query = $this->db->get(); return $query->result_array(); } function get_post($postID){ $this->db->select()->from('posts')->where(array('active'=>1,'postID'=>$postID))->order_by('date_added', 'desc'); $query=$this->db->get(); return $query->first_row('array'); } ... } Controller (posts.php): <?php class Posts extends CI_Controller{ function __construct(){ parent::__construct(); $this->load->model('post'); } function index(){ //$this->load->model('post'); $data['posts']=$this->post->get_posts(); $this->load->view('post_index',$data); } function post($postID){ $data['post']=$this->post->get_post($postID); $this->load->view('post',$data); } ... View (post.php): <h1>Blog</h1> <?php if(!isset($post)) { ?> <p>The page was accessed incorrectly</p> <? } else { ?> <h2><?=$post['title']?></h2> <?=$post['post']?> <? } ?> I can browse to localhost/posts and retrieve all posts. But when i click on read more (detail), i got: Object not found! The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. If you think this is a server error, please contact the webmaster. Error 404 The url is : http://localhost/posts/post/1 How do I track this error? Thx for any help. |
Welcome Guest, Not a member yet? Register Sign In |