5
<? switch($data['type']) : ?>
<? case 'log': ?>

    <? while ($row = $data['loop']->fetch()) : ?>
        <table class="t-errors">
            <tr>
                <td>
                    <b>IP:</b> <? echo $row['LogShellIP']; ?>
                    <b>Command:</b> <? echo $row['LogShellCommand']; ?>
                    <b>Executed:</b> <? echo $row['LogShellReturn']; ?>
                    <b>Time:</b> <? echo format::time($row['LogShellTime']); ?>
                </td>
            </tr>
        </table>
    <? endwhile; ?>

<? break; ?>

<? case 'fatal': ?>
<? case 'warning': ?>
<? case 'notice': ?>
<? case 'unknown': ?>

    <? while ($row = $data['loop']->fetch()) : ?>
        <table class="t-errors">
            <tr>
                <td <? if ($row['LogErrorSeen'] == 0) { echo 'class="e-selected"'; } ?>>
                    <b>String:</b> <? echo $row['LogErrorString']; ?>
                    <b>File:</b> <? echo $row['LogErrorFile']; ?>
                    <b>Line:</b> <? echo $row['LogErrorLine']; ?>
                    <b>Context:</b> <? echo $row['LogErrorContext']; ?>
                    <b>Ip:</b> <? echo $row['LogErrorIP']; ?>
                    <b>Time:</b> <? echo format::time($row['LogErrorTime']); ?>
                </td>
            </tr>
        </table>
    <? endwhile; ?>

<? break; ?>
<? endswitch; ?>                    

I'm getting this error:

Parse error: syntax error, unexpected T_INLINE_HTML, expecting T_ENDSWITCH or T_CASE or T_DEFAULT in /Applications/XAMPP/xamppfiles/htdocs/Smooth Framework/tpl/terminal.tpl.php on line 33

Where line 33 is the line 2 of this script. This is inserted in a template context. What's wrong with this? He is expecting a T_CASE and that's what is there!

j08691
  • 204,283
  • 31
  • 260
  • 272
Shoe
  • 74,840
  • 36
  • 166
  • 272
  • THe error might be lurking in any of the 31 lines you've ommited – Mchl Feb 08 '11 at 15:17
  • First off, don't use short-tags. And don't keep breaking in and out of PHP context like that, it's **really** ugly. If you fix that, you'll probably find the error goes away right away. – ircmaxell Feb 08 '11 at 15:18
  • @Mchl, not at all. PHP error lines are referring always to the previous or current line. So that Error in line 33 could be in line 33 or 32, not previous. Since the 32 is shown, why didn't PHP stopped at 32 instead? – Shoe Feb 08 '11 at 15:20
  • @Charlie: In this case, you're right. But in the general case the error can be anywhere in the file. The line number quoted is only where the *compiler/parser* realized the error, not where it actually occurred. It could be 30 lines back. In this case is not. Reformat your code and you'll be fine... – ircmaxell Feb 08 '11 at 15:22
  • @Charlie Pigarelli: Do not be so sure about that ;) Depending on what you have in previous lines, a missing comma or a `?>` in a `//` comment can possibly manifest many lines below. – Mchl Feb 08 '11 at 15:22
  • @Charlie: No, if a parse error occurs in line 32 it can be, that the actual fault is already in line 11. – NikiC Feb 08 '11 at 15:23
  • @ircmaxell, @Mchl, @nikic Yeah, thanks. I did got it with ircmaxell's comments. ;) There were no needs of 3 comments. ;) – Shoe Feb 08 '11 at 15:47

2 Answers2

9

merge line 1 and 2

  <? switch($data['type']):
     case 'log': ?>

see the comment in this link (jeremia at gmx dot at 28-Jan-2008 02:52)

Haim Evgi
  • 123,187
  • 45
  • 217
  • 223
  • 1
    Exactly: [LXR: language_parser.y](http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_language_parser.y#405). No `T_INLINE_HTML` allowed there. – NikiC Feb 08 '11 at 15:25
3

The parser expects a T_CASE token but finds the newline after switch($data['type']) : ?>.

switch (1) : ?> <? case 1: break; endswitch;

gives a parse error and so does

switch (1) : ?>\n<? case 1: break; endswitch;

while

switch (1) : ?><? case 1: break; endswitch; 

does not. ;-)

lordstyx
  • 775
  • 3
  • 12
  • 29
rik
  • 8,592
  • 1
  • 26
  • 21