Question

I'm trying to setup CodeIgniter (v2.1.4) with Query Strings and having problems with passing variables. The pages work when the controller_trigger and function_trigger are passed:

example.org/?c=page&m=index

But when I try to pass a variable:

example.org/?c=page&m=view&id=1

The script throws 'Missing argument' and 'Undefined variable' errors.

In 'application/config/config.php' I've set:

$config['enable_query_strings'] = TRUE;

In 'application/config/routes.php' I have:

$route['default_controller'] = "page";

And my Controller looks like:

<?php

class Page extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->model('page_model');
    }

    public function index()
    {
        $data['title'] = 'Page Title';

        $this->load->view('templates/header', $data);
        $this->load->view('page/page_index', $data);
        $this->load->view('templates/footer');
    }

    public function view($id)
    {
        $data['title'] = 'Id Page Title';

        $data['page_item'] = $this->page_model->get_page($id);

        $this->load->view('templates/header', $data);
        $this->load->view('page/page_view', $data);
        $this->load->view('templates/footer');
    }

}

Does anyone know what I've missed?

Any help would be greatly appreciated

Was it helpful?

Solution

In your config.php change:

$config['allow_get_array']      = TRUE;    #example.com?who=me&what=something&where=here

OTHER TIPS

Write it like this

example.org?c=page&m=index

without "/"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top