本文介绍了如何解决此错误"mysql_fetch_assoc()期望参数1为资源,在boolean中给出"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
错误...
$hoje = strtotime(date("d-m-Y"));
$db = new DBConfig();
$db -> config();
$db->conn();
$query = mysql_query("SELECT * FROM products WHERE auto_pub = ".$hoje) or die(mysql_error());
while($res = mysql_fetch_assoc($query)) {
$query = mysql_query("UPDATE products SET publicado = '0' WHERE auto_pub = ".$hoje) or die(mysql_error());
}
$db->close();
推荐答案
$query
用于while
之前和while
内部...将变量的名称更改为$query2
,例如:
$query
is used before the while
and inside the while
... Change the name of the variable to $query2
, for example:
$hoje = strtotime(date("d-m-Y"));
$db = new DBConfig();
$db -> config();
$db->conn();
$query = mysql_query("SELECT * FROM products WHERE auto_pub = ".$hoje) or die(mysql_error());
while($res = mysql_fetch_assoc($query)) {
$query2 = mysql_query("UPDATE products SET publicado = '0' WHERE auto_pub = ".$hoje) or die(mysql_error());
}
$db->close();
希望有帮助.
这篇关于如何解决此错误"mysql_fetch_assoc()期望参数1为资源,在boolean中给出"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!