ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

$IN->GBL Undefined

July 15, 2009 4:24pm

Subscribe [3]
  • #1 / Jul 15, 2009 4:24pm

    Peter Baker

    49 posts

    I’m trying to use the global $IN method to grab a url query value, but it’s saying GBL is undefined:

    Example url:
    http://donq.mine.nu/test/_chainselect/?_value=5

    - I do include global $DB, $IN; at the top of the script
    - I do have PHP enabled, and tried both on input and output
    - I’ve tried numerous different query keys and values

    $IN->GBL(‘_value’) results in:

    Undefined property: Input::$GBL in /Users/pete/Projects/Clients/2009-07 - Don Q/src/system/core/core.functions.php(637) : eval()'d code on line 8

    print_r($IN) results in:

    Input Object
    (
        [AGENT] => Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) AppleWebKit/530.18 (KHTML, like Gecko) Version/4.0.1 Safari/530.18
        [IP] => 127.0.0.1
        [SID] => 
        [URI] => /test/_chainselect/
        [QSTR] => 
        [Pages_QSTR] => 
        [SEGS] => Array
            (
                [1] => test
                [2] => _chainselect
            )
    
        [trim_input] => 1
        [global_vars] => Array
            (
            )
    
        [whitelisted] => n
        [blacklisted] => n
        [reserved] => Array
            (
                [0] => css
                [1] => trackback
            )
    
        [make_safe] => Array
            (
                [0] => RET
                [1] => XSS
                [2] => URI
                [3] => ACT
            )
    
    )

    No where does GBL even show up, any clue?

  • #2 / Jul 15, 2009 5:27pm

    Ingmar

    29245 posts

    Have you seen the docs on the Input class? Superglobals are explained in somewhat more detail there.

  • #3 / Jul 15, 2009 5:44pm

    Peter Baker

    49 posts

    Of course I read that doc. It doesn’t address my issue at all.

    I get how the superglobals are supposed to work, but I don’t understand why they’re not working. Every other example on the docs page works except for $ID->GBL(). That’s what I’m asking for help with figuring out. Shouldn’t a var dump of $IN contain a GBL array if it was working? And if the input class was working, wouldn’t a check for $IN->GBL(‘_value’) return false if it couldn’t find it (according to the docs), but it’s showing GBL as undefined. Everything but GBL works for me. Why is that and where should look to figure it out?

  • #4 / Jul 15, 2009 6:02pm

    Peter Baker

    49 posts

    Or, I suppose GBL wouldn’t show up in the var dump, since it’s a class function, but I still don’t get why calling it as a function returns nothing.

  • #5 / Jul 15, 2009 6:20pm

    Peter Baker

    49 posts

    Even just print_r($_GET) returns only this:

    Array ( [/test/_chainselect/] => )

    I don’t get it. FYI, I checked another non-EE site on my same dev server, GET variables do get passed by print_r($_GET), so I’m lost in some EE-specific problem.

  • #6 / Jul 15, 2009 7:45pm

    Greg Aker

    6022 posts

    Can you show us what your URL rewrite looks like?  That may be the culprit here.  If you take it out of the equation, can you get _value to dump?

    -greg

  • #7 / Jul 15, 2009 8:02pm

    Peter Baker

    49 posts

    It must be in the .htaccess. I whittled down my .htaccess to the 3 lines that are required to recreate it:

    RewriteEngine On
    # <a href="http://expressionengine.com/wiki/Remove_index.php_From_URLs/#Include_List_Method">http://expressionengine.com/wiki/Remove_index.php_From_URLs/#Include_List_Method</a>
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    Also, if I go to:

    /index.php/test/_chainselect/?id=&name=field_id_8&_value=5

    And do:

    global $IN;
    echo $IN->GBL('_value');

    ...I get “5”.

    If I remove index.php/ and use that .htaccess code, I get to the right page, I don’t see 5.
    If I use that .htaccess code AND go to the url with index.php/, I do see 5.

    I’m obviously not a mod rewrite master, or I’d have thought to check .htaccess at the start. Any ideas?

  • #8 / Jul 15, 2009 8:09pm

    Greg Aker

    6022 posts

    Do you have to force query strings on this server?

    -greg

  • #9 / Jul 15, 2009 8:15pm

    Peter Baker

    49 posts

    No, I tried $_GET on another site on the same install of MAMP Pro, and tried turning Force Query Strings on and off for this one; same deal.

  • #10 / Jul 15, 2009 8:22pm

    Peter Baker

    49 posts

    Here is the phpinfo():
    http://lunabar.mine.nu/

  • #11 / Jul 15, 2009 8:23pm

    Greg Aker

    6022 posts

    Unless you’ve done some configuring, I don’t believe you need query strings when you run on MAMP.  That being said, for the time being go ahead & remove the .htaccess from the mix and put index.php back in your control panel and give it another try.

    -greg

  • #12 / Jul 16, 2009 12:24am

    Peter Baker

    49 posts

    Yeah, like I said, it works that way (index.php included in the url, with htaccess or not). I’m using the htaccess method from the EE wiki, any idea why this is happening?

    If I go to:

    /index.php/test/_chainselect/?id=&name=field_id_8&_value=5
    global $IN;
    echo $IN->GBL('_value');

    ...It works, I get “5”.

    If I remove index.php/ and use that .htaccess code, I get to the right page, I don’t see 5.
    If I use that .htaccess code AND go to the url with index.php/, I do see 5.

     

  • #13 / Jul 16, 2009 1:19am

    John Henry Donovan

    12339 posts

    Peter,

    In your htaccess, change

    RewriteRule ^(.*)$ /index.php?/$1 [L]

    to this by removing the ?

    RewriteRule ^(.*)$ /index.php/$1 [L]
  • #14 / Jul 16, 2009 1:37am

    Peter Baker

    49 posts

    Wow John, thanks, that did it. Thanks so much.
    I need to bone up on my mod rewrite.

    Seems strange that Leevi Graham would include the question mark in his .htaccess generator:
    http://leevigraham.com/cms-customisation/expressionengine/lg-htaccess-generator/

    Anyways, thanks for the help.

  • #15 / Jul 16, 2009 1:52am

    John Henry Donovan

    12339 posts

    Peter,

    Glad to help. Leevi just includes a broad range of stuff for the htaccess. A lot isn’t necessary and it is a base to customise yourself. Feel free to start a new thread if you have any more questions.

    P.S. I have to come clean. I ran into the same problem the other day and it took me a very long time to figure out 😊

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases