We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10395
    • 96 Posts
    Hi,

    Can someone tell me what might be wrong with this code?

    <?php
    
    echo '<p style="text-align:center;"> [ <a href="index.php?id=4&catid=1">Category 1</a> | 
    <a href="index.php?id=4&catid=2">Category 2</a> | 
    <a href="index.php?id=4&catid=3">Category 3</a> ] </p>';
    
    $id = $_GET['catid'];
    
    echo $id;
    
    ?>
    


    $id returns empty, even when $_GET[’catid’] is set and I dont know why.

    Thanks.
      • 10395
      • 96 Posts
      Hi,

      Zi helped me with some suggestions but i’m having another problem.

      When $_GET[’catid’] is set, it only outputs the number 3...which would be correct if it only outputted that number when $_GET[’catid’] equalled 3, but it’s not. It just keeps outputting that number, even when $_GET[’catid’] isn’t set, which is weird.

      So say i have 3 url’s.

      index.php?id=4&catid=1, index.php?id=4&catid=2, index.php?id=4&catid=3

      When i try to output $_GET[’catid’], all it will output is 3 and not 1 or 2.

      Thanks.
      • Garry Nutting Reply #3, 18 years ago
        How is the code being called? If this is in a snippet, make sure you call the snippet uncached ... [!mySnippet!]

        Hope that helps, Garry
          Garry Nutting
          Senior Developer
          MODX, LLC

          Email: [email protected]
          Twitter: @garryn
          Web: modx.com
          • 10395
          • 96 Posts
          Yes it is a snippet, but I don’t understand what you mean by calling it uncached, i just used the [[snippetname]] to call it.
          • Garry Nutting Reply #5, 18 years ago
            Hi Gaia, to call the snippet use: [!snippetname!]

            That means the snippet will be run every time the page is loaded and won’t be cached with the rest of the content. wink This is of particular use especially when using $_GET variables in snippets.
              Garry Nutting
              Senior Developer
              MODX, LLC

              Email: [email protected]
              Twitter: @garryn
              Web: modx.com
              • 10395
              • 96 Posts
              ah, ok i see what you mean, it’s working perfectly now ^_^. Thanks.