We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24531
    • 213 Posts
    i’m adding custom features to modx, i wrote a script which i try to make a snippet now. my efforts fail on line 2
    Error: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
    i’ve figured out that
    when i call snippet with something like this
    [[model? marka=`55`]]
    it doesn’t pass parameter so instead of correct mysql_query i get something like
    ’SELECT * FROM modx_shina_man WHERE id =’
    and it should be
    ’SELECT * FROM modx_shina_man WHERE id = 55’

    $res = mysql_query(’SELECT * FROM ’.$modx->db->config[’table_prefix’].’shina_man WHERE id=’.$marka);

    it’s the very beginning of the snippet.
    help me i’m stuck
      • 24531
      • 213 Posts
      yep i figured it out already. strangely enough i could bet that some snippets work without ampersand...
      nevertheless, thanks for quick reply!!
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Actually the first parameter should work if it immediately follows the ? (no spaces!). Think URL query strings, except you can have a space between parameters.
          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
          • 24531
          • 213 Posts
          yes it should but it doesn’t.
            • 7231
            • 4,205 Posts
            You should always use the syntax [[SnippetName? &param=`value` &param=`value`]]. This will always work. I have seen a few snippets that do not follow this syntax in the documentation but it is good practice to do it this way.

            ListIndexer for example drops the & and the back-ticks in its documentation [[listIndexer?LIn_root=3,6,88]] I have not used this snippet so I can’t say if this will work or not. All of the example calls in the docs are single parameter calls, so this may work with a single parameter but with multiple ones I don’t think it will.

            Anyway stick to the standard and you won’t go wrong.
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don't know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 24381
              • 9 Posts
              fyi, always use the & , even on the 1st param
              cool