我有这段代码,我收到了这些错误:
警告:mysqli :: query():无法在第299行的C:\ xampp \ htdocs \ pliroforiaka \ grammateiakos_upallilos.php中获取mysqli
注意:尝试在第301行的C:\ xampp \ htdocs \ pliroforiaka \ grammateiakos_upallilos.php中获取非对象的属性
警告:mysqli :: close():无法在第317行的C:\ xampp \ htdocs \ pliroforiaka \ grammateiakos_upallilos.php中获取mysqli
<table name="table5" id="table5" width="941" border="1" cellspacing="0" cellpadding="3" align="center">
<form name="form5" class="form5" id="form5" action="stoixeiarantevou.php" method="post">
<td>
<?php
$sql = "SELECT username FROM giatros";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
?>
<div id="doc">
<select name="Doctor">
<?php
// output data of each row
while($row = $result->fetch_assoc()) {
?>
<option value="<?php echo $row['Doctor']; ?>"><?php echo $row['username'];?> </option>
<?php
}
?>
</select>
</div>
<?php
}
$conn->close();
?>
Ημερομηνία: <input type="text" id="Hmeromhnia" name="Hmeromhnia" required> <br>
Ώρα: <input type="text" id="Wra" name="Wra" required><br>
<input type="button" value="Δημιουργία" id="btnsubmit" onclick="submitForm3()" required>
</td>
</form>
</table>
<script>
function submitForm3() {
// Get the first form with the name
// Hopefully there is only one, but there are more, select the correct index
var frm = document.getElementsByName('form5')[0];
frm.submit(); // Submit
frm.reset(); // Reset
alert("Τα στοιχεία σας ανανεώθηκαν επιτυχώς");
return false; // Prevent page refresh
}
</script>
</td>
</tr>
答案 0 :(得分:1)
这里的问题是您已提前关闭数据库连接。 删除此行
$ conn-> close();