We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9572
    • 56 Posts
    Quote from: BobRay at Sep 22, 2007, 09:38 PM



    It seems to me that the only thing left is that when $input is set from the passed parameter, it’s the wrong variable type.

    You might try casting it:

    return $xmlData->SONGHISTORY->SONG[(int)$input]->TITLE;

    I changed that and it looks like it works now! I guess that was the problem all along, This is good to know for future reference
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I’m not sure where your $input value comes from, but if it’s from POST or GET, those are always passed as strings.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 9572
        • 56 Posts
        Quote from: sottwell at Sep 23, 2007, 11:32 AM

        I’m not sure where your $input value comes from, but if it’s from POST or GET, those are always passed as strings.
        $input is passed in from the snippet call (not sure if thats POST or GET)
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: fegul at Sep 23, 2007, 11:41 AM

          Quote from: sottwell at Sep 23, 2007, 11:32 AM

          I’m not sure where your $input value comes from, but if it’s from POST or GET, those are always passed as strings.
          $input is passed in from the snippet call (not sure if thats POST or GET)
          Neither, but all snippet parameters are treated as string values when passed via a snippet tag (i.e. [[ ]] or [! !]), as well. When calling a snippet using $modx->runSnippet() however, the values will reflect the actual type that is passed in via the second parameter (an array of snippet parameters).
            • 3749
            • 24,544 Posts
            Quote from: OpenGeek at Sep 23, 2007, 12:06 PM

            Neither, but all snippet parameters are treated as string values when passed via a snippet tag (i.e. [[ ]] or [! !]), as well. When calling a snippet using $modx->runSnippet() however, the values will reflect the actual type that is passed in via the second parameter (an array of snippet parameters).

            Very nice. Can I assume that it’s impossible for a miscreant to cause a snippet to execute or pass it fake parameters using POST or GET?

            Bob
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 33372
              • 1,611 Posts
              This is where your register_globals setting comes in... although I believe that the variable scope inside snippets is limited anyway.
                "Things are not what they appear to be; nor are they otherwise." - Buddha

                "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                • 9572
                • 56 Posts
                This snippet thing is really starting to bug me.

                Whenever I call the snippet twice in a chunk (with different array locations in the parameter), I get the following;
                Fatal error: Cannot redeclare get_xml_specify_ua() (previously declared in /home/fegul/public_html/modx/manager/includes/document.parser.class.inc.php(766) : eval()'d code:5) in /home/fegul/public_html/modx/manager/includes/document.parser.class.inc.php(766) : eval()'d code on line 18


                How do I go about actually having the main function run once and display twice on a page?

                EDIT: Fixed it by reading this part of the wiki; http://wiki.modxcms.com/index.php/Creating_Snippets#Wrap_functions_inside_.21function_exists_conditional_if_the_resource_is_needed_to_run_more_than_once_on_a_page