I have a quiz on my site that is read in php. When people answer the questions, I want 2 things to happen;
1) a score gets calculated - 5 pts for a right answer and 0 for a wrong answer, so I put this code to calculate the score:
if ($POST[Q1] == "1") {
$Q1 = 0;
} else if ($POST[Q1] == "2") {
$Q1 = 5;
} else if ($POST[Q1] == "3") {
$Q1 = 0;
} else if ($POST[Q1] == "4") {
$Q1 = 0;
}
..etc
Where "2" is the right answer.
I also have a calculation to see if it's a passing or failing score:
{$result = $Q1 + $Q2 + $Q3 + $Q4 + $Q5 + $Q6 + $Q7 + $Q8 + $Q9 + $Q10 + $Q11 + $Q12 + $Q13 + $Q14 + $Q15 + $Q16 + $Q17 + $Q18 + $Q19 + $Q20;}
if ($result >= "80") {
$are = Pass;
} else if ($result < "80") {
$are = Fail;
}
2)an answer is displayed.
Depending on the answer given, I want something displayed saying something like "Right answer, because..." or "Wrong answer, because...".
So I put in this code after the result calculation:
if ($POST[Q1] == "1") {
$A1 = Wrong, because...;
} else if ($POST[Q1] == "2") {
$A1 = Right, because...;
} else if ($POST[Q1] == "3") {
$A1 = Wrong, because...;
} else if ($POST[Q1] == "4") {
$A1 = Wrong, because...;
}
but I keep getting the following error:
Parse error: parse error, unexpected T_NEW in .... on line 195
Any ideas why I keep getting this error?