-4

Parse error: syntax error, unexpected '$result' (T_VARIABLE) in C:\xampp\htdocs\quiz\serverDB.php on line 159

I can't figure out what's wrong >_<

<?php
            $fetch="SELECT questions.question_id, questions.question, answers.answer
                    FROM questions
                    WHERE isActive=1
                    INNER JOIN answers
                    ON questions.question_id=answers.question_id ORDER BY questions.question_id;"
            $result = mysql_query($fetch, $connection);
            if(!$result){
                die( "Database selection failed: " . mysql_error());
                }
                while($row = mysql_fetch_array($result)){
                    echo "<form method=\"post\" action=\"editQuestions.php\">";
                    echo "<tr>";
                    echo "<input type=\"hidden\" name=\"index\" value=\"".$row['question_id']."\">";
                        for($ctrCell=1;$ctrCell<=6;$ctrCell++){
                        echo "<td>";
                        echo $row[$ctrCell];
                        echo "</td>";
                        }
                        echo "<td style=\"border-left: solid 1px #00478F;\" class=\"action\"><input type=\"submit\" name=\"btnAction\" value=\"EDIT\"></td>";
                        echo "<td style=\"border-right: solid 1px #00478F;\" class=\"action\"><input type=\"submit\" name=\"btnAction\" value=\"DELETE\"></td>";
                    echo "</tr>";
                    echo "</form>";
                }
?>
korzero
  • 1
  • 3

2 Answers2

1

You have missed / misplaced a semi-colon in $fetch:

$fetch="SELECT questions.question_id, questions.question, answers.answer
                    FROM questions
                    WHERE isActive=1
                    INNER JOIN answers
                    ON questions.question_id=answers.question_id ORDER BY questions.question_id;";
                                                                                               ^ ^
Thamilhan
  • 13,040
  • 5
  • 37
  • 59
0

$fetch="SELECT questions.question_id, questions.question, answers.answer FROM questions WHERE isActive=1 INNER JOIN answers ON questions.question_id=answers.question_id ORDER BY questions.question_id";

Digpal Singh
  • 166
  • 1
  • 5