警告:mysql_fetch_array()希望参数1是资源,布尔值在第6行的C:\xampp\htdocs\final2\ah.php中给出
可能重复:警告:mysql_fetch_array()希望参数1是资源,布尔值在第6行的C:\xampp\htdocs\final2\ah.php中给出,php,sql,Php,Sql,可能重复: 我是PHP的新手,所以我为代码的混乱道歉 我不知道如何修复此错误: 警告:mysql_fetch_array()希望参数1是资源,布尔值在第6行的C:\xampp\htdocs\final2\ah.php中给出 请帮助我了解如何解决这个问题 以下是我的php代码: <?php include('config_db.php'); $today = (date('Y-m-d')); $query = "select * from inventory.re
我是PHP的新手,所以我为代码的混乱道歉 我不知道如何修复此错误: 警告:mysql_fetch_array()希望参数1是资源,布尔值在第6行的C:\xampp\htdocs\final2\ah.php中给出 请帮助我了解如何解决这个问题 以下是我的php代码:
<?php
include('config_db.php');
$today = (date('Y-m-d'));
$query = "select * from inventory.reservation,inventory.machine where inventory.reservation.item_code = inventory.machine.item_code and inventory.reservation.date_to > '$today'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$this->avail_num = $row['avail_num'] + $row['num_reserve'];
$this->num_reserve = 0;
}
$query = "delete from inventory.reservation where num_reserve = 0";
mysql_query($query) or die('<p>ERROR, query Failed</p>');
?>
您必须使用
和
而不是第二个where子句
$query = "select * from inventory.reservation,inventory.machine where inventory.reservation.item_code = inventory.machine.item_code and inventory.reservation.date_to > '".$today."'";
您必须使用
和
而不是第二个where子句
$query = "select * from inventory.reservation,inventory.machine where inventory.reservation.item_code = inventory.machine.item_code and inventory.reservation.date_to > '".$today."'";
改变
到
您在查询中包含了两个where..更改
$query = "select * from inventory.reservation,inventory.machine where inventory.reservation.item_code = inventory.machine.item_code where inventory.reservation.date_to > '$today'";
到
您在查询中包含了两个where子句。只需将第二个where子句替换为“and”,它就可以工作了:
试试这个:
select * from inventory.reservation,inventory.machine where inventory.reservation.item_code = inventory.machine.item_code and inventory.reservation.date_to > '$today'";
注意:如果可能,请使用带别名的列名从数据库中获取数据:
大致如下:
SELECT tbl1.Column1 AS 'CusomName', tbl1.Column2 AS 'CustomName',... FROM 'Table1' tbl1 WHERE Condition1 = Condition2 AND Condition3 = Condition4
这可能有助于编写复杂的查询,并且在连接两个表时非常有用。只需将第二个“where”子句替换为“and”,它就可以工作了:
试试这个:
select * from inventory.reservation,inventory.machine where inventory.reservation.item_code = inventory.machine.item_code and inventory.reservation.date_to > '$today'";
注意:如果可能,请使用带别名的列名从数据库中获取数据:
大致如下:
SELECT tbl1.Column1 AS 'CusomName', tbl1.Column2 AS 'CustomName',... FROM 'Table1' tbl1 WHERE Condition1 = Condition2 AND Condition3 = Condition4
这可能有助于您编写复杂的查询,并且在连接两个表时非常有用。您的查询中有两个where子句似乎有误。oops第二个where应该在其中,而您的查询中有两个where子句似乎有误。oops第二个where应该在其中,您是否尝试过我的更新代码?你的问题解决了吗?还是仍然出现错误?您是否在我的更新中尝试了您的代码?你的问题解决了吗?还是仍然会出错?