数据库选择错误/解析错误:语法错误

时间:2015-12-09 04:46:53

标签: php mysql checkbox multiple-choice

解析错误:语法错误,第159行的C:\ xampp \ htdocs \ quiz \ serverDB.php中的意外'$ result'(T_VARIABLE)

我无法弄清楚什么是错的> _<

<?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>";
                }
?>

2 个答案:

答案 0 :(得分:1)

您错过/错放了$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;";
                                                                                               ^ ^

答案 1 :(得分:0)

$ fetch =“SELECT questions.question_id,questions.question,answers.answer                     从问题                     WHERE isActive = 1                     INNER JOIN回答                     ON questions.question_id = answers.question_id ORDER BY questions.question_id“;