MyBB Community Forums

Full Version: Plugin error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6
So I get this error trying out my new plugin.
Parse error: syntax error, unexpected T_STRING in /home/gfxcafen/public_html/test/inc/plugins/status.php on line 26
Here is line 26 any ideas?
find_replace_templatesets("postbit", "#".preg_quote('{$post['onlinestatus']}')."#i", '{$post['onlinestatus']} <br /><strong>{$post['$fid1212']}  </strong>'); 
find_replace_templatesets("postbit", "#".preg_quote("{$post['onlinestatus']}")."#i", "{$post['onlinestatus']} <br /><strong>{$post['$fid1212']}  </strong>"); 

you are using ' and not escaping the ones "inside" of the 2/3rd param. changed the 2/3rd param outer ' to " and should work
(2011-05-04, 12:38 AM)pavemen Wrote: [ -> ]
find_replace_templatesets("postbit", "#".preg_quote("{$post['onlinestatus']}")."#i", "{$post['onlinestatus']} <br /><strong>{$post['$fid1212']}  </strong>"); 

you are using ' and not escaping the ones "inside" of the 2/3rd param. changed the 2/3rd param outer ' to " and should work
Same error.

sorry, i suck at regex and i hate writing the find_replace function. it was a best guess at the time
NP thanks for the try, maybe someone else can help me. Smile
only other thing to try is go back to your original and then escape the single quotes inside the "post" variables
This is wrong:
<strong>{$post['$fid1212']}  </strong>

If you're using a variable inside of the brackets for an array you do not use the single quotes around it.
Also, in this situation you might be better off adjusting the $post['onlinestatus'] on the fly in your plugin.

I'm assuming you're running your hook off of "postbit" anyways, which means you've got access to the $post variable array. So instead of messing with templates, in your hook you just do:

$post['onlinestatus'] .= "<br /><strong>{$post[$fid1212]}</strong>";

Right before you return from the plugin function. This will load your data on the fly without messing with templates and is the better way to do this.
Replace above with this;
find_replace_templatesets("postbit", "#".preg_quote("{$post['onlinestatus']}")."#i", "{$post['onlinestatus']} <br /><strong>{$post['fidX']}</strong>");
Where X is your Custom Profile Field ID.
(2011-05-04, 03:23 AM)Dylan M. Wrote: [ -> ]
$post['onlinestatus'] .= "<br /><strong>{$post[$fid1212]}</strong>";

In 1.6.4, a variable as an array key won't be liked very much due to the new security in the templates.
Pages: 1 2 3 4 5 6