"Disco Octopus" <di**********@yahoo.com> wrote in message
news:9s***************************@40tude.net...
Jim Michaels wrote:
"Disco Octopus" <di**********@yahoo.com> wrote in message
news:ke***************************@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.