• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controller not working as expected

#1
[eluser]StefanAlexandru[/eluser]
Hi everyone, I am new to CI, and I am trying to build up a classified site , so I've just encountered a problem which I couldn't understand.

So here is my code :

Controller :
Code:
<?php
class Ads extends CI_Controller {


        public function index(){
                $this->load->model('General');
                 $data['anunt']=$this->General->adbyID();
                 $this->load->view('anunt', $data);
        }

      


                
      
}
?>

Model:
Code:
class General extends CI_Model {

        function __construct() {
                parent::__construct();
    }

        public function adbyID() {
                $id=$this->uri->segment(2);
                $this->db->where('postID', $id);
                $query=$this->db->get('v_ads');

                return $query->result();
         }
}


So, when I am calling the controller like this :
http://www.domain.net/subdomain/ads/10/
I am getting a 404 error, but if I make a new function, not putting all the code in the index function, everything is working fine.

So my question is : Why I can't perform that actions in the index function of the controller ?

It wouldn't be a real problem but it's for seo purposes to have
Code:
http://www.domain.net/subdomain/ad/10/
instead of
Code:
http://www.domain.net/subdomain/ads/function/10/

Thanks in advance and sorry for my bad english.


Messages In This Thread
Controller not working as expected - by El Forum - 07-21-2011, 10:34 AM
Controller not working as expected - by El Forum - 07-21-2011, 10:38 AM
Controller not working as expected - by El Forum - 07-21-2011, 11:04 AM
Controller not working as expected - by El Forum - 07-21-2011, 11:57 AM
Controller not working as expected - by El Forum - 07-21-2011, 12:01 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.