unexpected ELSE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim Michaels

    #1

    unexpected ELSE

    C:\prj\quiz\wit husers>php tareports.php
    PHP Parse error: syntax error, unexpected T_ELSE in
    C:\prj\quiz\wit husers\tareport s.php on line 205


    this is the section of code.

    if (isset($row4)) {
    if (isset($row5)) { //answer given?
    if ($row4['answer_tag']==$row5['answer_tag']) {
    ?>
    <div class=answer>An swer:<br />
    <?php echo $row4['answer_tag']; ?>. <?php echo $row5['answer']; ?><?php if
    ($row5['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
    ?>viewraimg.php ?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
    </div>
    <br />
    <?php
    $ncorrect++;
    } else { //no answer or answer is wrong
    ?>
    <div class=answer>An swer 1:<br />
    <?php echo $row5['answer_tag']; ?>. <?php echo $row5['answer']; ?><?php if
    ($row5['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
    ?>viewraimg.php ?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
    </div>
    <div class=answer>An swer 2:<br />
    <?php echo $row4['answer_tag']; ?>. <?php echo $row4['answer']; ?><?php if
    ($row4['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
    ?>viewraimg.php ?id=<?php echo $row4['answer_id']; ?>" /><?php } ?>
    </div>
    <br />
    <?php
    $nwrong++;
    }

    ....else blah blah


    I need a 2nd pair of eyes. I've gone as far as I can debugging this thing.
    my braces match. I even eliminated a stray open switch statement that I
    copied from code elsewhere. Am I running into a PHP parser bug that doesn't
    like certain IF constructs here?

    I once got an error message about an unexpected } because one was missing in
    my code or something like that. It was an odd error message for the problem.
    and I think I am getting another one of these.


  • Disco Octopus

    #2
    Re: unexpected ELSE

    Jim Michaels wrote:
    [color=blue]
    > C:\prj\quiz\wit husers>php tareports.php
    > PHP Parse error: syntax error, unexpected T_ELSE in
    > C:\prj\quiz\wit husers\tareport s.php on line 205
    >
    >
    > this is the section of code.
    >
    > if (isset($row4)) {
    > if (isset($row5)) { //answer given?
    > if ($row4['answer_tag']==$row5['answer_tag']) {
    > ?>
    > <div class=answer>An swer:<br />
    > <?php echo $row4['answer_tag']; ?>. <?php echo $row5['answer']; ?><?php if
    > ($row5['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
    > ?>viewraimg.php ?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
    > </div>
    > <br />
    > <?php
    > $ncorrect++;
    > } else { //no answer or answer is wrong[/color]

    ----------------^
    .... this char here

    [color=blue]
    > ?>
    > <div class=answer>An swer 1:<br />
    > <?php echo $row5['answer_tag']; ?>. <?php echo $row5['answer']; ?><?php if
    > ($row5['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
    > ?>viewraimg.php ?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
    > </div>
    > <div class=answer>An swer 2:<br />
    > <?php echo $row4['answer_tag']; ?>. <?php echo $row4['answer']; ?><?php if
    > ($row4['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
    > ?>viewraimg.php ?id=<?php echo $row4['answer_id']; ?>" /><?php } ?>
    > </div>
    > <br />
    > <?php
    > $nwrong++;
    > }[/color]
    ---------^
    .... is ended by this one here, therefore an else is not expected here...
    [color=blue]
    > ...else blah blah
    >
    >
    > I need a 2nd pair of eyes. I've gone as far as I can debugging this thing.
    > my braces match. I even eliminated a stray open switch statement that I
    > copied from code elsewhere. Am I running into a PHP parser bug that doesn't
    > like certain IF constructs here?
    >
    > I once got an error message about an unexpected } because one was missing in
    > my code or something like that. It was an odd error message for the problem.
    > and I think I am getting another one of these.[/color]


    Just at a glance I found the above.

    I use a text editor called Textpad. It allows me to match open/close
    braces/brackets/defined programming block containers. This is how I found
    this.


    --
    dont pick your nose if it is sore

    Comment

    • Jim Michaels

      #3
      Re: unexpected ELSE


      "Disco Octopus" <discooctopus@y ahoo.com> wrote in message
      news:kenkjdfz58 h8$.yj85d8ygh72 .dlg@40tude.net ...[color=blue]
      > Jim Michaels wrote:
      >[color=green]
      >> C:\prj\quiz\wit husers>php tareports.php
      >> PHP Parse error: syntax error, unexpected T_ELSE in
      >> C:\prj\quiz\wit husers\tareport s.php on line 205
      >>
      >>
      >> this is the section of code.
      >>
      >> if (isset($row4)) {
      >> if (isset($row5)) { //answer given?
      >> if ($row4['answer_tag']==$row5['answer_tag']) {
      >> ?>
      >> <div class=answer>An swer:<br />
      >> <?php echo $row4['answer_tag']; ?>. <?php echo $row5['answer']; ?><?php
      >> if
      >> ($row5['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
      >> ?>viewraimg.php ?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
      >> </div>
      >> <br />
      >> <?php
      >> $ncorrect++;
      >> } else { //no answer or answer is wrong[/color]
      >
      > ----------------^
      > ... this char here[/color]

      the open curly bracket? that's a standard if construct.
      if () {
      } else {
      }
      am I not doing this right? I don't see it.
      [color=blue]
      >
      >[color=green]
      >> ?>
      >> <div class=answer>An swer 1:<br />
      >> <?php echo $row5['answer_tag']; ?>. <?php echo $row5['answer']; ?><?php
      >> if
      >> ($row5['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
      >> ?>viewraimg.php ?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
      >> </div>
      >> <div class=answer>An swer 2:<br />
      >> <?php echo $row4['answer_tag']; ?>. <?php echo $row4['answer']; ?><?php
      >> if
      >> ($row4['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
      >> ?>viewraimg.php ?id=<?php echo $row4['answer_id']; ?>" /><?php } ?>
      >> </div>
      >> <br />
      >> <?php
      >> $nwrong++;
      >> }[/color]
      > ---------^
      > ... is ended by this one here, therefore an else is not expected here...
      >[color=green]
      >> ...else blah blah
      >>
      >>
      >> I need a 2nd pair of eyes. I've gone as far as I can debugging this
      >> thing.
      >> my braces match. I even eliminated a stray open switch statement that I
      >> copied from code elsewhere. Am I running into a PHP parser bug that
      >> doesn't
      >> like certain IF constructs here?
      >>
      >> I once got an error message about an unexpected } because one was missing
      >> in
      >> my code or something like that. It was an odd error message for the
      >> problem.
      >> and I think I am getting another one of these.[/color]
      >
      >
      > Just at a glance I found the above.
      >
      > I use a text editor called Textpad. It allows me to match open/close
      > braces/brackets/defined programming block containers. This is how I found
      > this.
      >
      >
      > --
      > dont pick your nose if it is sore[/color]


      Comment

      • Jim Michaels

        #4
        Re: unexpected ELSE


        "Disco Octopus" <discooctopus@y ahoo.com> wrote in message
        news:kenkjdfz58 h8$.yj85d8ygh72 .dlg@40tude.net ...[color=blue]
        > Jim Michaels wrote:
        >[color=green]
        >> C:\prj\quiz\wit husers>php tareports.php
        >> PHP Parse error: syntax error, unexpected T_ELSE in
        >> C:\prj\quiz\wit husers\tareport s.php on line 205
        >>
        >>
        >> this is the section of code.
        >>
        >> if (isset($row4)) {
        >> if (isset($row5)) { //answer given?
        >> if ($row4['answer_tag']==$row5['answer_tag']) {
        >> ?>
        >> <div class=answer>An swer:<br />
        >> <?php echo $row4['answer_tag']; ?>. <?php echo $row5['answer']; ?><?php
        >> if
        >> ($row5['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
        >> ?>viewraimg.php ?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
        >> </div>
        >> <br />
        >> <?php
        >> $ncorrect++;
        >> } else { //no answer or answer is wrong[/color]
        >
        > ----------------^
        > ... this char here
        >
        >[color=green]
        >> ?>
        >> <div class=answer>An swer 1:<br />
        >> <?php echo $row5['answer_tag']; ?>. <?php echo $row5['answer']; ?><?php
        >> if
        >> ($row5['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
        >> ?>viewraimg.php ?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
        >> </div>
        >> <div class=answer>An swer 2:<br />
        >> <?php echo $row4['answer_tag']; ?>. <?php echo $row4['answer']; ?><?php
        >> if
        >> ($row4['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
        >> ?>viewraimg.php ?id=<?php echo $row4['answer_id']; ?>" /><?php } ?>
        >> </div>
        >> <br />
        >> <?php
        >> $nwrong++;
        >> }[/color]
        > ---------^
        > ... is ended by this one here, therefore an else is not expected here...
        >[color=green]
        >> ...else blah blah
        >>
        >>
        >> I need a 2nd pair of eyes. I've gone as far as I can debugging this
        >> thing.
        >> my braces match. I even eliminated a stray open switch statement that I
        >> copied from code elsewhere. Am I running into a PHP parser bug that
        >> doesn't
        >> like certain IF constructs here?
        >>
        >> I once got an error message about an unexpected } because one was missing
        >> in
        >> my code or something like that. It was an odd error message for the
        >> problem.
        >> and I think I am getting another one of these.[/color]
        >
        >
        > Just at a glance I found the above.
        >
        > I use a text editor called Textpad. It allows me to match open/close
        > braces/brackets/defined programming block containers. This is how I found
        > this.[/color]

        tried textpad. dreamweaver does the same thing as control-shift-M. Found
        the open switch statement by printing out the code and drawing lines between
        the brackets. turned out to be mostly dead code so I eliminated it. but it
        was farther up the code block. didn't eliminate the error message. all it
        did was move it.

        the entire file (with headers for execution) can be found for a while at



        tareports.php is the one with the problem.


        Comment

        • Disco Octopus

          #5
          Re: unexpected ELSE

          Jim Michaels wrote:
          [color=blue]
          > "Disco Octopus" <discooctopus@y ahoo.com> wrote in message
          > news:kenkjdfz58 h8$.yj85d8ygh72 .dlg@40tude.net ...[color=green]
          >> Jim Michaels wrote:
          >>[color=darkred]
          >>> C:\prj\quiz\wit husers>php tareports.php
          >>> PHP Parse error: syntax error, unexpected T_ELSE in
          >>> C:\prj\quiz\wit husers\tareport s.php on line 205
          >>>
          >>>
          >>> this is the section of code.
          >>>
          >>> if (isset($row4)) {
          >>> if (isset($row5)) { //answer given?
          >>> if ($row4['answer_tag']==$row5['answer_tag']) {
          >>> ?>
          >>> <div class=answer>An swer:<br />
          >>> <?php echo $row4['answer_tag']; ?>. <?php echo $row5['answer']; ?><?php
          >>> if
          >>> ($row5['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
          >>> ?>viewraimg.php ?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
          >>> </div>
          >>> <br />
          >>> <?php
          >>> $ncorrect++;
          >>> } else { //no answer or answer is wrong[/color]
          >>
          >> ----------------^
          >> ... this char here[/color]
          >
          > the open curly bracket? that's a standard if construct.
          > if () {
          > } else {
          > }
          > am I not doing this right? I don't see it.
          >[/color]



          This was the first part of my response...




          [color=blue][color=green]
          >>
          >>[color=darkred]
          >>> ?>
          >>> <div class=answer>An swer 1:<br />
          >>> <?php echo $row5['answer_tag']; ?>. <?php echo $row5['answer']; ?><?php
          >>> if
          >>> ($row5['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
          >>> ?>viewraimg.php ?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
          >>> </div>
          >>> <div class=answer>An swer 2:<br />
          >>> <?php echo $row4['answer_tag']; ?>. <?php echo $row4['answer']; ?><?php
          >>> if
          >>> ($row4['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
          >>> ?>viewraimg.php ?id=<?php echo $row4['answer_id']; ?>" /><?php } ?>
          >>> </div>
          >>> <br />
          >>> <?php
          >>> $nwrong++;
          >>> }[/color]
          >> --------^
          >> ... is ended by this one here, therefore an else is not expected here...
          >>[/color][/color]



          I think you may have missed the *second* part of my responce to you.



          --
          freeball

          Comment

          • Jim Michaels

            #6
            Re: unexpected ELSE - interpreter bug?


            "Disco Octopus" <discooctopus@y ahoo.com> wrote in message
            news:9swp96b32t s0.kg4pm4ryto4w .dlg@40tude.net ...[color=blue]
            > Jim Michaels wrote:
            >[color=green]
            >> "Disco Octopus" <discooctopus@y ahoo.com> wrote in message
            >> news:kenkjdfz58 h8$.yj85d8ygh72 .dlg@40tude.net ...[color=darkred]
            >>> Jim Michaels wrote:
            >>>
            >>>> C:\prj\quiz\wit husers>php tareports.php
            >>>> PHP Parse error: syntax error, unexpected T_ELSE in
            >>>> C:\prj\quiz\wit husers\tareport s.php on line 205
            >>>>
            >>>>
            >>>> this is the section of code.
            >>>>
            >>>> if (isset($row4)) {
            >>>> if (isset($row5)) { //answer given?
            >>>> if ($row4['answer_tag']==$row5['answer_tag']) {
            >>>> ?>
            >>>> <div class=answer>An swer:<br />
            >>>> <?php echo $row4['answer_tag']; ?>. <?php echo $row5['answer'];
            >>>> ?><?php
            >>>> if
            >>>> ($row5['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
            >>>> ?>viewraimg.php ?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
            >>>> </div>
            >>>> <br />
            >>>> <?php
            >>>> $ncorrect++;
            >>>> } else { //no answer or answer is wrong
            >>>
            >>> ----------------^
            >>> ... this char here[/color]
            >>
            >> the open curly bracket? that's a standard if construct.
            >> if () {
            >> } else {
            >> }
            >> am I not doing this right? I don't see it.
            >>[/color]
            >
            >
            >
            > This was the first part of my response...
            >
            >
            >
            >
            >[color=green][color=darkred]
            >>>
            >>>
            >>>> ?>
            >>>> <div class=answer>An swer 1:<br />
            >>>> <?php echo $row5['answer_tag']; ?>. <?php echo $row5['answer'];
            >>>> ?><?php
            >>>> if
            >>>> ($row5['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
            >>>> ?>viewraimg.php ?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
            >>>> </div>
            >>>> <div class=answer>An swer 2:<br />
            >>>> <?php echo $row4['answer_tag']; ?>. <?php echo $row4['answer'];
            >>>> ?><?php
            >>>> if
            >>>> ($row4['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
            >>>> ?>viewraimg.php ?id=<?php echo $row4['answer_id']; ?>" /><?php } ?>
            >>>> </div>
            >>>> <br />
            >>>> <?php
            >>>> $nwrong++;
            >>>> }
            >>> --------^
            >>> ... is ended by this one here, therefore an else is not expected here...[/color][/color]
            > I think you may have missed the *second* part of my responce to you.[/color]


            I have the same kind of construct which didn't get an error at lines
            134-153.
            if ($row2['ra_id_given_id ']!=0) {
            $q3=mysql_query ("SELECT * FROM quiz_report_que stions WHERE
            rq_id=$row2[ra_id_given_id]", $link);
            $row3=mysql_fet ch_array($q3);
            if ($row2['correct_ra_id']!=0) {
            $q4=mysql_query ("SELECT * FROM quiz_report_ans wers WHERE
            ra_id=$row2[correct_ra_id]", $link);
            $row4=mysql_fet ch_array($q4);
            if ($row4['answer_tag']==$row3['answer_tag']) {
            $ncorrect++;
            } else {
            $nwrong++;
            }
            } else { //bad test
            $bad=true;
            }
            } else { // user gave no answer. doesn't matter if no answer available.
            if ($row2['correct_ra_id']!=0) {
            //answer available. consider it wrong. don't even have to look
            it up.
            $nwrong++;
            }
            }
            }


            One clue:

            I commented out the else statements because both were giving the same
            "unexpected " error (?!?interpreter bug?) then it complained about
            unexpected case. (!?!) I double-checked the syntax. looks valid for a
            switch(){}. something else above that first else error is causing the
            interpreter to go haywire.

            if (isset($row4)) {
            if (isset($row5)) { //answer given?
            if ($row4['answer_tag']==$row5['answer_tag']) {
            ?>
            <div class=answer>An swer given:<br />
            <?php echo $row4['answer_tag']; ?>. <?php echo $row5['answer']; ?><?php if
            ($row5['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
            ?>viewraimg.php ?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
            </div>
            <br />
            <?php
            $ncorrect++;
            } /*else { //no answer or answer is wrong
            ?>
            <div class=answer>An swer given:<br />
            <?php echo $row5['answer_tag']; ?>. <?php echo $row5['answer']; ?><?php if
            ($row5['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
            ?>viewraimg.php ?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
            </div>
            <div class=answer>Co rrect Answer:<br />
            <?php echo $row4['answer_tag']; ?>. <?php echo $row4['answer']; ?><?php if
            ($row4['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
            ?>viewraimg.php ?id=<?php echo $row4['answer_id']; ?>" /><?php } ?>
            </div>
            <br />
            <?php
            $nwrong++;
            }*/
            } /*else { //no answer given
            ?>
            <div class=answer>An swer given:<br />
            None.
            </div>
            <br />
            <?php
            $nwrong++;
            }*/
            } //else question has no correct answer. don't count.


            Comment

            • Simon

              #7
              Re: unexpected ELSE - interpreter bug?

              >[color=blue]
              > I have the same kind of construct which didn't get an error at lines
              > 134-153.
              > if ($row2['ra_id_given_id ']!=0) {
              > $q3=mysql_query ("SELECT * FROM quiz_report_que stions WHERE
              > rq_id=$row2[ra_id_given_id]", $link);
              > $row3=mysql_fet ch_array($q3);
              > if ($row2['correct_ra_id']!=0) {
              > $q4=mysql_query ("SELECT * FROM quiz_report_ans wers WHERE
              > ra_id=$row2[correct_ra_id]", $link);
              > $row4=mysql_fet ch_array($q4);
              > if ($row4['answer_tag']==$row3['answer_tag']) {
              > $ncorrect++;
              > } else {
              > $nwrong++;
              > }
              > } else { //bad test
              > $bad=true;
              > }
              > } else { // user gave no answer. doesn't matter if no answer
              > available.
              > if ($row2['correct_ra_id']!=0) {
              > //answer available. consider it wrong. don't even have to look
              > it up.
              > $nwrong++;
              > }
              > }
              > }
              >[/color]

              You have already been told by Disco Octopus what the problem is, (did you
              even read his reply?).
              Look at the code bellow and it will show you where the error is.

              if ($row2['ra_id_given_id ']!=0)
              {
              $q3=mysql_query ("SELECT * FROM quiz_report_que stions WHERE
              rq_id=$row2[ra_id_given_id]", $link);
              $row3=mysql_fet ch_array($q3);
              if ($row2['correct_ra_id']!=0)
              {
              $q4=mysql_query ("SELECT * FROM quiz_report_ans wers WHERE
              ra_id=$row2[correct_ra_id]", $link);
              $row4=mysql_fet ch_array($q4);
              if ($row4['answer_tag']==$row3['answer_tag'])
              {
              $ncorrect++;
              }
              else
              {
              $nwrong++;
              }
              }
              else
              { //bad test
              $bad=true;
              }
              ////////////////////////////////////////////////////
              // this else has no if!!!!
              ////////////////////////////////////////////////////
              }
              else
              { // user gave no answer. doesn't matter if no answer available.
              if ($row2['correct_ra_id']!=0)
              {
              //answer available. consider it wrong. don't even have to look
              it up.
              $nwrong++;
              }
              }
              }

              And in my experience, "(?!?interprete r bug?)" usually means that you are
              wrong.

              Simon
              --
              Own this domain today. We make your shopping experience easy. Friendly and quick customer service.

              Free URL redirection service. Turns a long URL into a much shorter one.


              Comment

              • Jim Michaels

                #8
                Re: unexpected ELSE - interpreter bug?


                "Simon" <spambucket@exa mple.com> wrote in message
                news:48pkm4Fl87 tlU1@individual .net...[color=blue][color=green]
                > >
                >> I have the same kind of construct which didn't get an error at lines
                >> 134-153.
                >> if ($row2['ra_id_given_id ']!=0) {
                >> $q3=mysql_query ("SELECT * FROM quiz_report_que stions WHERE
                >> rq_id=$row2[ra_id_given_id]", $link);
                >> $row3=mysql_fet ch_array($q3);
                >> if ($row2['correct_ra_id']!=0) {
                >> $q4=mysql_query ("SELECT * FROM quiz_report_ans wers WHERE
                >> ra_id=$row2[correct_ra_id]", $link);
                >> $row4=mysql_fet ch_array($q4);
                >> if ($row4['answer_tag']==$row3['answer_tag']) {
                >> $ncorrect++;
                >> } else {
                >> $nwrong++;
                >> }
                >> } else { //bad test
                >> $bad=true;
                >> }
                >> } else { // user gave no answer. doesn't matter if no answer
                >> available.
                >> if ($row2['correct_ra_id']!=0) {
                >> //answer available. consider it wrong. don't even have to look
                >> it up.
                >> $nwrong++;
                >> }
                >> }
                >> }
                >>[/color]
                >
                > You have already been told by Disco Octopus what the problem is, (did you
                > even read his reply?).
                > Look at the code bellow and it will show you where the error is.
                >
                > if ($row2['ra_id_given_id ']!=0)
                > {
                > $q3=mysql_query ("SELECT * FROM quiz_report_que stions WHERE
                > rq_id=$row2[ra_id_given_id]", $link);
                > $row3=mysql_fet ch_array($q3);
                > if ($row2['correct_ra_id']!=0)
                > {
                > $q4=mysql_query ("SELECT * FROM quiz_report_ans wers WHERE
                > ra_id=$row2[correct_ra_id]", $link);
                > $row4=mysql_fet ch_array($q4);
                > if ($row4['answer_tag']==$row3['answer_tag'])
                > {
                > $ncorrect++;
                > }
                > else
                > {
                > $nwrong++;
                > }
                > }
                > else
                > { //bad test
                > $bad=true;
                > }
                > ////////////////////////////////////////////////////
                > // this else has no if!!!!
                > ////////////////////////////////////////////////////
                > }
                > else
                > { // user gave no answer. doesn't matter if no answer available.
                > if ($row2['correct_ra_id']!=0)
                > {
                > //answer available. consider it wrong. don't even have to look
                > it up.
                > $nwrong++;
                > }
                > }
                > }[/color]


                see the if statement if ($row2['correct_ra_id']!=0) { for the one
                with the comment "bad test". it's obvious.
                for the one without the comment below your /////////// see if
                ($row2['ra_id_given_id ']!=0) { it goes with the one with the comment "user
                gave no answer". brackets match. already checked many times. I printed
                the code out and drew lines between the curly brackets to make sure my if
                statements were correct, and checked them with a brace checker.

                it turns out I am not the only one to cause the interpreter to crash with
                this "unexpected T_ELSE" error message (causes VC6 JIT debugger to come up).
                there is a bug logged at php.net. the first guy didn't give his full code
                so the bug report didn't go very far.

                the last curly brace came from the end of a while() statement so it's bogus.

                I did find an echo line around line 306 that didn't have a semicolon. (4.3.8
                didn't give me an error about a missing else or case statement) I
                discovered that because I used 4.3.8 to execute it. and then after I fixed
                that bug, 4.3.8 hung and I can't kill it. maybe it's because of the
                sessions or mysql being used in conjection with command-line (sessions?).

                [color=blue]
                >
                > And in my experience, "(?!?interprete r bug?)" usually means that you are
                > wrong.
                >
                > Simon
                > --
                > http://urlkick.com/
                > Free URL redirection service. Turns a long URL into a much shorter one.
                >[/color]


                Comment

                • Tim Streater

                  #9
                  Re: unexpected ELSE

                  In article <16qdnZbt75oqx7 rZRVn-sQ@comcast.com> ,
                  "Jim Michaels" <NOSPAMFORjmich ae3@yahoo.com> wrote:
                  [color=blue]
                  > C:\prj\quiz\wit husers>php tareports.php
                  > PHP Parse error: syntax error, unexpected T_ELSE in
                  > C:\prj\quiz\wit husers\tareport s.php on line 205
                  >
                  >
                  > this is the section of code.
                  >
                  > if (isset($row4)) {
                  > if (isset($row5)) { //answer given?
                  > if ($row4['answer_tag']==$row5['answer_tag']) {
                  > ?>
                  > <div class=answer>An swer:<br />
                  > <?php echo $row4['answer_tag']; ?>. <?php echo $row5['answer']; ?><?php if
                  > ($row5['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
                  > ?>viewraimg.php ?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
                  > </div>
                  > <br />
                  > <?php
                  > $ncorrect++;
                  > } else { //no answer or answer is wrong
                  > ?>
                  > <div class=answer>An swer 1:<br />
                  > <?php echo $row5['answer_tag']; ?>. <?php echo $row5['answer']; ?><?php if
                  > ($row5['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
                  > ?>viewraimg.php ?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
                  > </div>
                  > <div class=answer>An swer 2:<br />
                  > <?php echo $row4['answer_tag']; ?>. <?php echo $row4['answer']; ?><?php if
                  > ($row4['is_img']) { ?><img src="<?php echo getconfigvar("b asepath");
                  > ?>viewraimg.php ?id=<?php echo $row4['answer_id']; ?>" /><?php } ?>
                  > </div>
                  > <br />
                  > <?php
                  > $nwrong++;
                  > }
                  >
                  > ...else blah blah
                  >
                  >
                  > I need a 2nd pair of eyes. I've gone as far as I can debugging this thing.
                  > my braces match. I even eliminated a stray open switch statement that I
                  > copied from code elsewhere. Am I running into a PHP parser bug that doesn't
                  > like certain IF constructs here?
                  >
                  > I once got an error message about an unexpected } because one was missing in
                  > my code or something like that. It was an odd error message for the problem.
                  > and I think I am getting another one of these.[/color]

                  Not that this is going to help but ...

                  I have to say I find code laid out like this to be unreadable. I tend to
                  line up ifs, elses, and braces so I can easily see where blocks start
                  and end and which else matches with which if. Is it tedious to do this?
                  A bit but it saves huge amounts of time. For editing I use TextWrangler
                  as that gives syntax-colouring - useful when you have lots of quotes
                  kicking about.

                  Also if you have lots of nested ifs and elses you probably want to
                  rethink what you are doing and how you are doing it.

                  -- tim

                  Comment

                  Working...