if then else Syntax
Posted: 2016-08-29 04:04
I think that I have a problem with syntax in my if then else statement:
1 function questions_after_insert($data, $memberInfo, &$args){
2
3 // Compute Correct Answer
4 $id = makeSafe($data['selectedID']);
5 sql("UPDATE questions set correct_answer = number_1 + number_2 ", $eo);
6 if ($data['your_answer'] == $data['correct_answer']){
7 //if (8 == 8){
8 // answer is correct
9 sql("UPDATE questions SET number_correct = '1' WHERE id ='$id' ", $eo);
10 }else{
11 // answer is incorrect
12 sql("UPDATE questions SET number_correct = '0' WHERE id ='$id' ", $eo);
13 }
14 return TRUE;
15 }
I think that my syntax in line 6 is wrong. I store "your-answer" and "correct_answer" in my file, thus, I can see that the values are in fact equal, but the routine always falls thru to line 12.
If I disable line 6 and enable line 7, all works well.
I am hoping someone can help... it seems to me that sometimes plain ole PHP syntax is fine and sometimes it is not (with Appgini)... I have not yet sorted things out.
Thank you,
Buck
1 function questions_after_insert($data, $memberInfo, &$args){
2
3 // Compute Correct Answer
4 $id = makeSafe($data['selectedID']);
5 sql("UPDATE questions set correct_answer = number_1 + number_2 ", $eo);
6 if ($data['your_answer'] == $data['correct_answer']){
7 //if (8 == 8){
8 // answer is correct
9 sql("UPDATE questions SET number_correct = '1' WHERE id ='$id' ", $eo);
10 }else{
11 // answer is incorrect
12 sql("UPDATE questions SET number_correct = '0' WHERE id ='$id' ", $eo);
13 }
14 return TRUE;
15 }
I think that my syntax in line 6 is wrong. I store "your-answer" and "correct_answer" in my file, thus, I can see that the values are in fact equal, but the routine always falls thru to line 12.
If I disable line 6 and enable line 7, all works well.
I am hoping someone can help... it seems to me that sometimes plain ole PHP syntax is fine and sometimes it is not (with Appgini)... I have not yet sorted things out.
Thank you,
Buck