![]() |
Empty _GET array - unable to retrieve a 'get' variable - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Empty _GET array - unable to retrieve a 'get' variable (/showthread.php?tid=10758) |
Empty _GET array - unable to retrieve a 'get' variable - El Forum - 08-11-2008 [eluser]passenger[/eluser] I am unable to retrieve a variable passed using GET syntax: Code: http://www.domain.com/callback?foo=something Code: class Callback extends Controller { Code: no incoming ()Array ( ) This suggests that there is nothing in the GET array, although I think this is cleared by the input class. Nevertheless, I can't seem to get the value passed in the URL. In the config, I've set 'enable_query_strings' to be TRUE, but this makes no difference. None of my routes match this pattern, so it can't be that, and here is my .htaccess. Code: RewriteEngine on Any ideas? Empty _GET array - unable to retrieve a 'get' variable - El Forum - 08-11-2008 [eluser]missionsix[/eluser] have you enabled query strings in config.php? You might have to change your routing method from AUTO to something else as well. Empty _GET array - unable to retrieve a 'get' variable - El Forum - 08-12-2008 [eluser]passenger[/eluser] Hi MS: 1) Query Strings Yes. As I said in the original post: Quote:In the config, I’ve set ‘enable_query_strings’ to be TRUE, but this makes no difference. :-) Change your routing method What do you mean? Do you mean the "uri_protocol" in the config. If so, this no help - if I use anything other than AUTO in the URI Protocol, other areas of the site break. I am reticent to rewrite the site to work with a single method alone. So, no help I'm afraid - thanks anyway. This has me beaten for the moment, and I am now going to have to write a standalone PHP script to handle GETs, outside of CI. Which is a shame because I am sure CI can handle this, and I am thoroughly enjoying all other aspects of the framework! If anyone can post an example of using gets within a controller, and any config settings that are required, this might get me going. Thanks. Empty _GET array - unable to retrieve a 'get' variable - El Forum - 08-12-2008 [eluser]missionsix[/eluser] Do you need GET's? You can use the URI->segment() method to pull out parts of the url. so you can do: Code: /controller/method/foo/bar/ And you can access the other segments with: $this->uri->segment(3) , for foo, and $this->uri->segment(4), for bar. This probably doesn't help you though. In order to get Query Strings working on my box, i had to use this config setting: Code: $config['uri_protocol'] = "ORIG_PATH_INFO"; And then in my controller I used $_GET directly. Empty _GET array - unable to retrieve a 'get' variable - El Forum - 08-12-2008 [eluser]Colin Williams[/eluser] I've got query strings enabled and use uri protocol PATH_INFO or REQUEST_URI and it works just fine on all my projects. Your problem is elsewhere, possibly something with mod_rewrite rules Empty _GET array - unable to retrieve a 'get' variable - El Forum - 08-13-2008 [eluser]passenger[/eluser] [quote author="Colin Williams" date="1218597165"]I've got query strings enabled and use uri protocol PATH_INFO or REQUEST_URI and it works just fine on all my projects. Your problem is elsewhere, possibly something with mod_rewrite rules[/quote] Thanks Colin, Any chance you could post a simple, working example. No need to post the config as long as these are the only changes from base CI, and there are no routes/.htaccess in play. Thanks if you can, C Empty _GET array - unable to retrieve a 'get' variable - El Forum - 08-13-2008 [eluser]Colin Williams[/eluser] Umm... sure... Code: print $_GET['q']; and the config, just to be clear: Code: $config['uri_protocol'] = "PATH_INFO"; No .htaccess, no routing, and when I hit up http://localhost/index.php/test/?q=hello or even http://localhost/index.php/test?q=hello I see: Quote:hello CI 1.6.3 Empty _GET array - unable to retrieve a 'get' variable - El Forum - 08-13-2008 [eluser]Colin Williams[/eluser] Ugh.. I can see the error with your .htaccess right away Code: RewriteEngine on You have RewriteRule ^(.*)$ /index.php?/$1... see the index.php?/$1? Your rewrite is passing the whole path as a query string key. Just drop the ? Do RewriteRule ^(.*)$ /index.php/$1 [L] instead. Also, your third RewriteCond COMPLETELY NEGATES the previous two RewriteConds |