Welcome Guest, Not a member yet? Register   Sign In
Title after the id in the url gives 404
#1

[eluser]Dennizzz[/eluser]
Sorry for the maybe confusing title, but had to come up with something describing the situation right? :p

So i just started learning CI and like everyone i started making a blog looking at the tutorial and than adjusting it too how i code. I like my urls clean and starting with the id first so thats what im going for, something like http://example.com/blog/3434/this-is-my-...this-blog/ so started using the htacces, got it working, and started using the routes wich is working. Now whenever i call the blog using blog/3434/ it works fine, but whenever the url has the title in it, it gives me a 404 page.

Controller
Code:
class Blog extends CI_Controller {

    function index() {
       $this->load->model('blog_model');
       $this->load->helper('url');
       $this->load->helper('text');
       $data['rows'] = $this->blog_model->showBlogs();
       $this->load->view('blogs/blog_view', $data);
    }
    
    function view() {
        $this->load->model('blog_model');
        $data['rows'] = $this->blog_model->showSingleblog();
        $this->load->view('blogs/blog_singleview', $data);
    }
}

The specific model
Code:
function showSingleblog() {
        $query = 'SELECT title, author, date, content FROM blog WHERE id = ?';
        $blogid = $this->uri->segment(2);
        $q = $this->db->query($query, $blogid);

        if ($q->num_rows() > 0) {
            foreach ($q->result() as $row) {
                $data[] = $row;
            }
            return $data;
        }
    }

And the route
Code:
$route['blog/:num'] = "blog/view";

Tried all sorts of different searching terms on the forums and wiki but could not find anything, hope someone can help me with this.

edit: Sorry posted in the wrong forums, tought i was in the right one.


Messages In This Thread
Title after the id in the url gives 404 - by El Forum - 05-22-2011, 07:35 AM
Title after the id in the url gives 404 - by El Forum - 05-22-2011, 10:12 AM
Title after the id in the url gives 404 - by El Forum - 05-22-2011, 10:24 AM
Title after the id in the url gives 404 - by El Forum - 05-22-2011, 11:02 AM
Title after the id in the url gives 404 - by El Forum - 05-22-2011, 01:02 PM
Title after the id in the url gives 404 - by El Forum - 05-22-2011, 01:13 PM
Title after the id in the url gives 404 - by El Forum - 05-22-2011, 02:05 PM
Title after the id in the url gives 404 - by El Forum - 05-22-2011, 02:09 PM
Title after the id in the url gives 404 - by El Forum - 05-23-2011, 06:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB