Welcome Guest, Not a member yet? Register   Sign In
$this->uri->segment(#) not working
#1

[eluser]JayArias[/eluser]
I am trying to retrieve /people/USERNAME. But for some reason I get a 404 Error when requesting the segment.

Code:
$this->uri->segment(3)

I've tried ROUTES, and everything nothing works.
#2

[eluser]bretticus[/eluser]
[quote author="JayArias" date="1264231779"]I am trying to retrieve /people/USERNAME. But for some reason I get a 404 Error when requesting the segment.

Code:
$this->uri->segment(3)
[/quote]

You get a 404 only when you call $this->uri->segment(3) in your code?? That doesn't make sense. Is people your controller or a controller method? From the looks of your URL, it's your controller. Since the 2nd segment is typically reserved for your action/function/method, I doubt that you have methods for each username. Perhaps, you need to access the method? ie.

/people/person/USERNAME assuming you name your method "person."

Yes, routes would be perfect for this scenario if you want to drop the method from the URL. What have you tried thus far?
#3

[eluser]brandon.cordell[/eluser]
How do you have your project set up?

404 Error means the page you requested wasn't found. If you type http://google.com/this-does-not-exist.phtml
into your browser, you will get a 404 error. $this->uri->segment() just returns part of the current URI string.
#4

[eluser]vitoco[/eluser]
USERNAME is the 3rd or the 2nd segment, cause the structure is /controller/method/param1/.../paramN , so when you call /people/USERNAME , you're assuming that there is a method or function called USERNAME.

The "correct" way to call can be /people/profile/USERNAME or /people/data/USERNAME.




Theme © iAndrew 2016 - Forum software by © MyBB