这是我的代码片段:
if (!($stmt = $mysqli->prepare("SELECT * FROM CUSTOMER"))) {
echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
if (!$stmt->execute()) {
echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
}
$stmt->store_result();
echo "<table border=2 cellpadding=4>
<tr bgcolor=white>
<th>Name</th>
<th>Lname</th>
<th>Phone</th>
<th>Address</th>
<th>Discount</th>
<th>email</th>
</tr>";
while ($row = mysql_fetch_array($stmt)){
echo "<tr>
<td>".$row['Name']."</td>
<td>".$row['Lname']."</td>
<td>".$row['Phone']."</td>
<td>".$row['Address']."</td>
<td>".$row['Discount']."</td>
<td>".$row['email']."</td>
</tr>";
}
echo "</table>";
$stmt->free_result();
$mysqli->close();
?>
意思是 mysql_fetch_array() 期望参数 1 是资源。我检查了 myPHPadmin 中的查询,它运行良好。我不明白为什么这不会发布。