![]() |
getting values from urls - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: getting values from urls (/showthread.php?tid=14708) |
getting values from urls - El Forum - 01-12-2009 [eluser]Vitsaus[/eluser] Hi, I'm having troubles to get values from urls. I can get the name of the controller etc but if i try to do something like http://mysite.com/controller/1, it gives me errors. - Htaccess works, mod_rewrite works, everything should be ok there. - print $this->uri->rsegment(1); results correctly "controller" but if I try print $this->uri->rsegment(2); and try to get a value, I get a following error: Code: 404 Page Not Found So all it does is, that it assumes it as a some kind of controller, not variable value like index.php?id=1! I want it to be a value that I can pick up from URL. How to achieve that? However, is this wrong way to do it at all, should I use Session or something like that to solve this problem? Thanks. getting values from urls - El Forum - 01-12-2009 [eluser]sinvos[/eluser] Open your config file change the following values. $config['uri_protocal'] = "PATH_INFO"; //resolves page not found $config['enable_query_strings'] = TRUE; This resolved my issue with passing values in URL. Hope it solves your problem. getting values from urls - El Forum - 01-12-2009 [eluser]Vitsaus[/eluser] Nope, still not working the way it should. Gotta be something else, that I just haven't spotted yet. getting values from urls - El Forum - 01-12-2009 [eluser]sinvos[/eluser] did you try grabbing the info by using $_GET? foreach ($_GET as $key => $value) { if ($key=='id') $id=$value; } getting values from urls - El Forum - 01-12-2009 [eluser]Vitsaus[/eluser] Ha, managed to get it work. I was using the controllers the way they should not have been used in this case. It seems that I can only take a value when I use http://example.com/main/news/thisIsValue. If I use http://example.com/main/thisIsValue, it does not work same way. It's certainly not so easy to move away from procedural coding to oop(mvc) styled codin ![]() getting values from urls - El Forum - 01-13-2009 [eluser]xwero[/eluser] It has nothing to do with OOP or MVC. It's the common way frameworks identify the controller and its method. If you want to use one segment, you use routing Code: $route['main/(\d+)'] = 'main/news/$1'; |