Reply to Re: unexpected ELSE - interpreter bug?

Your name:

Reply:


Posted by Jim Michaels on 11/18/18 11:43

"Disco Octopus" <discooctopus@yahoo.com> wrote in message
news:9swp96b32ts0.kg4pm4ryto4w.dlg@40tude.net...
> Jim Michaels wrote:
>
>> "Disco Octopus" <discooctopus@yahoo.com> wrote in message
>> news:kenkjdfz58h8$.yj85d8ygh72.dlg@40tude.net...
>>> Jim Michaels wrote:
>>>
>>>> C:\prj\quiz\withusers>php tareports.php
>>>> PHP Parse error: syntax error, unexpected T_ELSE in
>>>> C:\prj\quiz\withusers\tareports.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>Answer:<br />
>>>> <?php echo $row4['answer_tag']; ?>. <?php echo $row5['answer'];
>>>> ?><?php
>>>> if
>>>> ($row5['is_img']) { ?><img src="<?php echo getconfigvar("basepath");
>>>> ?>viewraimg.php?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
>>>> </div>
>>>> <br />
>>>> <?php
>>>> $ncorrect++;
>>>> } else { //no answer or answer is wrong
>>>
>>> ----------------^
>>> ... this char here
>>
>> the open curly bracket? that's a standard if construct.
>> if () {
>> } else {
>> }
>> am I not doing this right? I don't see it.
>>
>
>
>
> This was the first part of my response...
>
>
>
>
>
>>>
>>>
>>>> ?>
>>>> <div class=answer>Answer 1:<br />
>>>> <?php echo $row5['answer_tag']; ?>. <?php echo $row5['answer'];
>>>> ?><?php
>>>> if
>>>> ($row5['is_img']) { ?><img src="<?php echo getconfigvar("basepath");
>>>> ?>viewraimg.php?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
>>>> </div>
>>>> <div class=answer>Answer 2:<br />
>>>> <?php echo $row4['answer_tag']; ?>. <?php echo $row4['answer'];
>>>> ?><?php
>>>> if
>>>> ($row4['is_img']) { ?><img src="<?php echo getconfigvar("basepath");
>>>> ?>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...
> I think you may have missed the *second* part of my responce to you.


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_questions WHERE
rq_id=$row2[ra_id_given_id]", $link);
$row3=mysql_fetch_array($q3);
if ($row2['correct_ra_id']!=0) {
$q4=mysql_query("SELECT * FROM quiz_report_answers WHERE
ra_id=$row2[correct_ra_id]", $link);
$row4=mysql_fetch_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>Answer given:<br />
<?php echo $row4['answer_tag']; ?>. <?php echo $row5['answer']; ?><?php if
($row5['is_img']) { ?><img src="<?php echo getconfigvar("basepath");
?>viewraimg.php?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
</div>
<br />
<?php
$ncorrect++;
} /*else { //no answer or answer is wrong
?>
<div class=answer>Answer given:<br />
<?php echo $row5['answer_tag']; ?>. <?php echo $row5['answer']; ?><?php if
($row5['is_img']) { ?><img src="<?php echo getconfigvar("basepath");
?>viewraimg.php?id=<?php echo $row5['answer_id']; ?>" /><?php } ?>
</div>
<div class=answer>Correct Answer:<br />
<?php echo $row4['answer_tag']; ?>. <?php echo $row4['answer']; ?><?php if
($row4['is_img']) { ?><img src="<?php echo getconfigvar("basepath");
?>viewraimg.php?id=<?php echo $row4['answer_id']; ?>" /><?php } ?>
</div>
<br />
<?php
$nwrong++;
}*/
} /*else { //no answer given
?>
<div class=answer>Answer given:<br />
None.
</div>
<br />
<?php
$nwrong++;
}*/
} //else question has no correct answer. don't count.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация