我有这个代码,我得到这些错误:
警告:mysqli::query(): cannot fetch mysqli in C:'xampp'htdocs'pliroforiaka'grammateiakos_upallilos.php on line 299
注意:试图在C:'xampp'htdocs'pliroforiaka'grammateiakos_upallilos.php中获得非对象的属性
警告:mysqli::close():无法在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>
这里的问题是您提前关闭了数据库连接。删除这一行
康涅狄格州→美元close ();