• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Uri segment not working

#1
[eluser]huangxiao[/eluser]
HI , I need some help please, i don't understand why uri segment is not working....it shows Object not found.

this is my controller....
Code:
class Firstpage extends CI_Controller {

   function index(){
        $site['content']='home';
        $this->load->view('includes/template',$site);

}


   function pagesite(){

    $p['page'] = $this->uri->segment(2);

     $this->load->view('pageviews',$p);

   }


}


this is my menuview

Code:
<li ><a href="&lt;?php echo base_url();?&gt;pagesite/home">Home</a></li>
  <li><a href="&lt;?php echo base_url();?&gt;pagesite/gallery">Gallery</a></li>

when i click the gallery the url will be like this.

Quote:http://localhost/mytest/pagesite/gallery

but it shows Object not found...can you help me please how do i fix this.


Thank you in advance.

#2
[eluser]rad11[/eluser]
Did you make, a function in pagesite controller named gallery or home ?

#3
[eluser]CroNiX[/eluser]
Your anchors are missing the controller name, firstpage.
Code:
<li ><a href="&lt;?php echo base_url();?&gt;firstpage/pagesite/home">Home</a></li>

And I believe this would be segment 3. Segment 1 = controller, segment 2 = method, segments 3+ are parameters.
Code:
$p['page'] = $this->uri->segment(3);

#4
[eluser]Kiran K[/eluser]
I think , what CroNiX said is right.



Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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