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.

Using php global IN to GET variables

June 23, 2010 12:52pm

Subscribe [3]
  • #1 / Jun 23, 2010 12:52pm

    aaron-h

    14 posts

    I’m having issues with using the global $IN to GET variables from the URL. I’m trying to get a variable from the URL and use in a query in a template. PHP parsing is set to input.

    I’ve got

    <?php global $IN; ?>
    declared early on in the template, and then I have
    {exp:query sql="SELECT cat_id,cat_folder FROM exp_gallery_categories WHERE gallery_id = '{gallery_number}' AND cat_id = '<?php =$IN->GBL('album_id', 'GET');?>'"}

    The XML file that gets output just does a query with blank cat_id. I’ve tried setting a PHP variable to the $IN->GBL and echoing and it just never gets set to anything.

    I feel like I’ve had this working on a different site in the past, am I missing something obvious? PHP 5.3.2 and EE 1.6.9.

    Thanks

  • #2 / Jun 23, 2010 7:09pm

    Brandon Jones

    5500 posts

    That syntax looks correct, but for now let’s keep it simple, without the query tag.

    global $IN;
    
    $album_id = $IN->GBL('album_id', 'GET');
    echo($album_id);

    Are you testing this without URL rewrite rules? Always completely disable .htaccess files when troubleshooting things like this.

  • #3 / Jun 24, 2010 11:38am

    aaron-h

    14 posts

    Good point. Disabling URL rewrite rules lets me access the variable in PHP.

    Thank you.

  • #4 / Jun 24, 2010 2:41pm

    Sue Crocker

    26054 posts

    Glad Brandon was able to help. Don’t hesitate to post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases