gpt4 book ai didi

php - 如何修复此错误 "mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in"?

转载 作者:行者123 更新时间:2023-11-29 04:57:10 25 4
gpt4 key购买 nike

这个问题在这里已经有了答案:




9年前关闭。




Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select



错误...

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/andar/public_html/sistema/admin/cron.php on line 19


$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();

最佳答案

$querywhile 之前使用在 while 内... 将变量名称更改为 $query2 , 例如:

$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();

希望能帮助到你。

关于php - 如何修复此错误 "mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5571907/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com