Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Routing problem, getting 404 with correct $routes
#1

[eluser]Unknown[/eluser]
Hi everyone,

I am new to CodeIgniter and I'm getting a strange behaviour in my code. What I want is to have a sort of person listing in my database and when I type the id of a given person, a page appears with all the informations we've got about this person in the database.

Just a simple thing. I succeeded with the news official tutorial thing and it doesn't work at all with this !

I wrote a controller inherited class which is named Person, with a viewPersonById method, just like that :

Code:
class Person extends CI_Controller{

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

public function index()
{
  
}

public function viewPersonById($parId){
  $data['person'] = $this->Person_Model->get($parId);
  
  $data['title'] = 'Person information';

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

My routes.php is written like this :

Code:
$route['people/(:any)'] = 'Person/viewPersonById/$1';

$route['news/create'] = 'news/create';
$route['news/modify/(:any)'] = 'news/modify/$1';
$route['news/(:any)'] = 'news/view/$1';
$route['news'] = 'news';

$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';

And all that I get is a 404 when I enter http://127.0.0.1:8888/ci/index.php/people/1 in my browser. What is wrong in my code ? I can't see it.

Any ideas ? Thanks and sorry for my poor english.




Theme © iAndrew 2016 - Forum software by © MyBB