how do I prevent error display if missing argument in URL? |
[eluser]netrox[/eluser]
I noticed that if I have this URL like this www.example.com/profile/id/4 it will display the profile of 4. But if someone enters with this URL www.example.com/profile/id Where id function is missing an argument, it generates an error. I don't want that error displayed at all. I tried "(!isset($id))" condition but it generated the error before it could reach that condition. How do I stop that? And redirect the page back to the index function of the given class?
[eluser]Joseph Wensley[/eluser]
You can try giving it a default, use something like Code: function id($id = NULL)
[eluser]BandonRandon[/eluser]
I know this is a little bit of an older post but I am using CI 2.0 and found this method to be simpler. This was the first post I found when searching how to do this so I thought I whould share how I'm doing it. Code: public function my_function($id='') //set the field here so it won't return false Hope this helps |
Welcome Guest, Not a member yet? Register Sign In |