tags:

views:

73

answers:

4

I have this part of code

<?php for ($j=0; $j < $count; $j++): ?>
    <?php if(isset($votes[$j])): ?>
          <dt>something something</dt>
          <dd>
              <span><?php echo $result; ?>%</span>
              <div class="bar">
              </div>
          </dd>
    <?php else: ?>
          <dt>info</dt>
          <dd>
              <span>0</span>
              <div class="bar">
                  <div style="width: 0px"></div>
              </div>
          </dd>
    <?php endif; ?>
<?php endfor; ?>

now Netbeans insists that on the endif line (near the end) there's a syntax error:

Error Syntax error: expected: exit, identifier, variable, function...

Is there some sort of known problem with the validation of endif on Netbeans ?

A: 
<?php for ($j=0; $j < $count; $j++): ?>

should be

<?php for ($j=0; $j < $count; $j++){ ?>

and dont forget the closing tag at the end }

But the guy above me is right ;)

Grumpy
+1  A: 

votes should be $votes

Coronatus
+2  A: 

I'm using NetBeans 6.8. Tried your code and it doesn't have problem with endif, instead it said there's something wrong with <dd>. I believe there's mistake on 2nd line, votes[$j] should be $votes[$j].

Ondrej Slinták
Could downvoter at least post a comment why did he/she give -1?
Ondrej Slinták
yeah I saw that error, changed it.. I think there might be an error on the HTML (this is just a piece of the code) however I don't see why it would interfere with the PHP.
Asaf
is there still error in your code then?
Ondrej Slinták
well, the errors were fixed.. the bug was still there and now it's not anymore, I'm pretty sure it's a bug in the program as mentioned on my own answer
Asaf
No, it's not a bug, you simply forgot to use $ there.
Ondrej Slinták
The thing is, I changed it and it still was just as it was.. it wasn't it I guarantee you.
Asaf
A: 

Using if( condition ): ... endif; is valid, maybe it's just a case of NetBeans not being configured to see them as such, in which case it would be something to address to their support team.

Lucanos