-2

Could you tell me why this error is happening?

( ! ) Parse error: syntax error, unexpected '{', expecting '(' in C:\wamp\www\torque\web\session.php on line 498

<!-- Data Summary Block -->
    <h4>Data Summary</h4>
    <div class="row center-block">
<?php if ($setZoomManually === 0) { ?>
      <!-- 2015.07.22 - edit by surfrock66 - Don't display anything if no variables are set (default) -->
<?php   if ( $var1 <> "" ) { ?>
      <div class="table-responsive">
        <table class="table">
          <thead>
            <tr>
              <th>Name</th>
              <th>Min/Max</th>
              <th>25th Pcnt</th>
              <th>75th Pcnt</th>
              <th>Mean</th>
              <th>Sparkline</th>
            </tr>
          </thead>
          <!-- 2015.08.05 - Edit by surfrock66 - Code to plot unlimited variables -->
          <tbody>
<?php       $i=1;
        while ( isset(${'var' . $i }) ) { ?>
            <tr>
              <td><strong><?php echo substr(${'v' . $i . '_label'}, 1, -1); ?></strong></td>
              <td><?php echo ${'min' . $i}.'/'.${'max' . $i}; ?></td>
              <td><?php echo ${'pcnt25data' . $i}; ?></td>
              <td><?php echo ${'pcnt75data' . $i}; ?></td>
              <td><?php echo ${'avg' . $i}; ?></td>
              <td><span class="line"><?php echo ${'sparkdata' . $i}; ?></span></td>
            </tr>
<?php       $i = $i + 1; } ?>
          </tbody>
        </table>
      </div>
<?php   } else { ?>
      <div align="center" style="padding-top:10px;">
        <h5><span class="label label-warning">No Variables Selected to Plot!</span></h5>
      </div>
<?      } ?>
<?php } else { ?>    <!-- here is the line of the unknown error -->
      <div align="center" style="padding-top:5px;">
        <h5><span class="label label-warning">Select a session first!</span></h5>
      </div>
<?php } ?>
    </div><br />

I am trying to put this code in my webserver to see my car's datalogs, but it is not working properly.

Here are the links to the surfrock webpage on github and econpy:

The most recent version of the code is from surfrock, but the code was made by econpy at first.

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
Piradata
  • 1
  • 3
  • 1
    As far as I can see, this piece of code has no problems with the `else`'s. Probably elsewhere in your code. – Qirel Jan 23 '16 at 20:43
  • Issue in these type of assigning ${'var' . $i } what is it – devpro Jan 23 '16 at 20:50
  • var is a variable that is obtained by POST. I really don't know why but when I changed ' } ?> ' by ' } } else { ?>' it works XD. unfortunately now I have a end of file error in the last line... what i have to make to close the question? – Piradata Jan 23 '16 at 21:08

1 Answers1

0

This is parse error which is very clear you are using unexpected brackets {

You can define this variable:

${'var' . $i }

As

$var . $i 

Note that it just an example you need to change all variable as like above mentioned.

devpro
  • 16,184
  • 3
  • 27
  • 38
  • 1
    Thanks for your answer, I've made it now XD – Piradata Jan 23 '16 at 21:16
  • Sure and share the feedback as well. @guilherme-ferreira-carvalho – devpro Jan 23 '16 at 21:18
  • Buddy, it gives another error... Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in C:\wamp\www\torque\web\session.php on line 243 – Piradata Jan 23 '16 at 21:26
  • @guilherme-ferreira-carvalho becuase no need to use in while loop. Yur while conditions is not good – devpro Jan 23 '16 at 21:30