【发布时间】:2020-02-22 01:15:40
【问题描述】:
我正在开发一个测验应用程序,我是这个错误:
致命错误:未捕获的错误:调用 C:\wamp64\ 中数组上的成员函数 fetch_assoc()
怎么了?
/**
* Get the Question
*/
$query = "SELECT * FROM questions
WHERE question_number = $number";
//Get result
$result = mysqli_query ($conn,$query);
$question = $result->fetch_assoc();
/*
* Get choices
*/
$query = "SELECT * FROM choices
WHERE question_number = $number";
//Get result
$result = mysqli_query ($conn,$query);
$choices = $result->fetch_assoc();
?>
<html>
<body>
<main>
<div class="container" >
<div class="current">Question 1 of 5</div>
<p class="question">
<?php echo $question ['text']; ?>
</p>
<?php while ($row = $choices->fetch_assoc()) : ?>
<li><input name="choice" type="radio value="<?php echo $row ['id'];?> " /><?php echo $row ['text']; ?></li>
<input type="submit" value="Sumbit your answer"/>
</ul>
</main>
</body>
</html>
<?php endwhile;
【问题讨论】:
-
请使用准备好的语句。