MyBB Community Forums

Full Version: I have a syntax error using the pagemanager addon
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Quote:Parse error: syntax error, unexpected T_STRING in ... eval()'d code on line

I get this code if I use the $mybb variable. How can I use myBB code insinde the pagemanager addon without getting these errors?
AdminCP > Configurations > Page Manager > Edit that page > and select No in "Use MyBB Template?" option.
Sry I didn't mention that but this option is deactivated already cause I want to use custom PHP.
Can you please paste the entire code using [code] tags ?
There's nothing special inside the code. Ive just used the xml provided by querschlaeger and echoed the uid of current user.

<?php

global $headerinclude, $header, $theme, $footer, $templates, $lang, $mybb, $global;

$template='<html>
<head>
<title>'.$pages['name'].'</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="'.$theme['borderwidth'].'" cellpadding="'.$theme['tablespace'].'" class="tborder">
<thead>
<tr>
<td class="thead">
<strong>'.$pages['name'].'</strong>
</td>
</tr>
</thead>
<tbody>
<tr>
<td class="trow1"><?php echo ($GLOBALS['mybb']->user['uid']); ?></td>
</tr>
</tbody>
</table>
<br />
{$footer}
</body>
</html>';

$template=str_replace("\'", "'", addslashes($template));

add_breadcrumb($pages['name']);

eval("\$page=\"".$template."\";");

output_page($page);

?>

I tried it also with
<?php
echo ($myBB->user['uid']);
?>
Replace;
<?php echo ($GLOBALS['mybb']->user['uid']); ?>
with;
{$mybb->user['uid']}
(2012-05-17, 11:38 AM)Yaldaram Wrote: [ -> ]Replace;
<?php echo ($GLOBALS['mybb']->user['uid']); ?>
with;
{$mybb->user['uid']}

Done. Exactly the same error. Here's my current code
<?php

global $headerinclude, $header, $theme, $footer, $templates, $lang, $mybb, $global;

$template='<html>
<head>
<title>'.$pages['name'].'</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="'.$theme['borderwidth'].'" cellpadding="'.$theme['tablespace'].'" class="tborder">
<thead>
<tr>
<td class="thead">
<strong>'.$pages['name'].'</strong>
</td>
</tr>
</thead>
<tbody>
<tr>
<td class="trow1">{$mybb->user['uid']}</td>
</tr>
</tbody>
</table>
<br />
{$footer}
</body>
</html>';

$template=str_replace("\'", "'", addslashes($template));

add_breadcrumb($pages['name']);

eval("\$page=\"".$template."\";");

output_page($page);

?>

Yaldaram no ideas?
Try escaping the ['uid']

{$mybb->user[\'uid\']}
Great Leefish, it's working now. Any other things to keep in mind while adding custom php code into the pagecontent?
Hmm, I don't really use it very much - most of my issues came with not escaping though. I think you also need to escape apostrophe's in text blocks in your html as well.
Pages: 1 2