This section contains detailed articles elaborating on some of the common issues phpBB users encounter while using the product. Articles submitted by members of the community are checked for accuracy by the relevant phpBB Team. If you do not find the answer to your question here, we recommend looking through the Support Section as well as using the Site Wide Search.

Parse error: eval()'d code

Description: How to fix 'eval()'d code' errors with templates.

In Categories:

Link to this article: Select All
[url=https://www.phpbb.com/support/docs/en/3.0/kb/article/parse-error-evald-code/]Knowledge Base - Parse error: eval()'d code[/url]

Overview
  • eval()'d parse errors are related to the template switches used in the phpBB template system. There are a number of possible causes to an eval() parse error and below they are listed.
    • If you are trying to add a script such as hitbox, fastcounter or anything that has <!-- BEGIN WHATEVER CODE --> and <!-- END WHATEVER CODE --> statements in it to a .tpl/.html file, you may be receiving such errors as
      Parse error: parse error, unexpected T_STRING in /root/phpBB/includes/template.php(127) : eval()'d code on line 50
    • This is due to how phpBB handles <!-- BEGIN --> and <!-- END -->'s. The template system is set-up to interpret these in special ways, such as loops and switches, and not having such an object between them results in parse errors.
    • So, to fix it delete the 'BEGIN' and 'END' in your HTML comments. You should also write all of your comments in lower case. ex:

      Code: Select all

      <!-- BEGIN FASTCOUNTER CODE -->
      <a href="http://member.bcentral.com/cgi-bin/fc/fastcounter-login?2440090" target="_top">
      <img border="0" src="http://fastcounter.bcentral.com/fastcounter?2440090+4880187"></a>
      <!-- END FASTCOUNTER CODE -->
      <br>
      <!-- BEGIN FASTCOUNTER LINK -->
      <font face="arial" size="1">
      <a href="http://fastcounter.bcentral.com/fc-join" target="_top">FastCounter by bCentral</a></font><br>
      <!-- END FASTCOUNTER LINK -->


      Will be changed to this:

      Code: Select all

      <!-- fastcounter code -->
      <a href="http://member.bcentral.com/cgi-bin/fc/fastcounter-login?2440090" target="_top">
      <img border="0" src="http://fastcounter.bcentral.com/fastcounter?2440090+4880187"></a>
      <!-- fastcounter code -->
      <br>
      <!-- fastcounter code -->
      <font face="arial" size="1">
      <a href="http://fastcounter.bcentral.com/fc-join" target="_top">FastCounter by bCentral</a></font><br>
      <!-- fastcounter code -->
    • If that is not the problem then you might be using switches incorrectly. Every switch should be on its own line.
    • This is NOT correct code:

      Code: Select all

      some html code <!-- BEGIN switch_user_online -->
      some other html code
    • This code is not correct before there is some text before switch. This is correct code:

      Code: Select all

      some html code
      <!-- BEGIN switch_user_online -->
      some other html code
    • Broken switches will also have a similar effect, for example

      Code: Select all

      <!-- BEGIN switch_user_online 
      is an incomplete switch and will cause a parse error.
    • The last possible problem with switches which may cause an error is having a begin switch without it's corresponding end switch, for example

      Code: Select all

      <!-- BEGIN switch_user_online -->
      would need to have its corresponding

      Code: Select all

      <!-- END switch_user_online -->