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
yep i figured it out already. strangely enough i could bet that some snippets work without ampersand...
nevertheless, thanks for quick reply!!
-
☆ 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.
yes it should but it doesn’t.
You should always use the syntax [[SnippetName? ¶m=`value` ¶m=`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.