2015-12-09 101 views
-4

解析错误:语法错误,意想不到 '$结果'(T_VARIABLE)在C:\ XAMPP \ htdocs中\测验\ serverDB.php上线159数据库选择错误/解析错误:语法错误

我不能弄清楚什么是错的> _ <

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

回答

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;"; 
                          ^^ 
+0

哦,谢谢!我现在可以继续解决下一个问题了......哈哈哈!^_ ^没有注意到错位的分号-_- – korzero

+1

@korzero如果能解决你的问题,你能否接受答案? –

0

$取=“SELECT questions.question_id,questions.question,answers.answer FROM questions WHERE isActive = 1 INNER JOIN答案 ON questions.question_id = answers.question_id ORDER BY questions.question_id“;