我几乎不敢发布此消息,因为自动搜索返回的前20个问题都被遗忘了。我已经阅读了已经提出的每个问题,我的问题似乎有所不同。
我的查询工作正常,因为它提供了正确的数据作为回复。但是,我仍然收到此错误,我无法弄清楚原因。这是代码:
$acOneLowestCostQuery = "SELECT * FROM $acSupplierOne where quotePartNumber = '$acPartNumberOne' ORDER BY quoteCost ASC LIMIT 1" ;
$acOneLowestCost = mysqli_query($con, $acOneLowestCostQuery);
while ($row = mysqli_fetch_array($acOneLowestCost)) {
$acOnePartNumber = $row['quotePartNumber'];
$acOneLowestCost = $row['quoteCost'];
?>
我的表格输出正确的信息,但表格上方是:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given in ... on line 199
第199行
while ($row = mysqli_fetch_array($acOneLowestCost)) {
我不明白的是:
有人会帮我理解为什么会出现这种错误吗?我宁愿修复问题,然后使用错误报告来显示它。
答案 0 :(得分:3)
问题在于变量命名:
$acOneLowestCost = mysqli_query($con, $acOneLowestCostQuery);
// here $acOneLowestCost is mysqli_result
while ($row = mysqli_fetch_array($acOneLowestCost)) {
$acOnePartNumber = $row['quotePartNumber'];
// and here it becomes a string which then passed to mysqli_fetch_array
$acOneLowestCost = $row['quoteCost'];