警告: mysql_fetch_assoc()要求参数1为资源,布尔值在第104行的C:\ xampp \ htdocs \ Arsenal Website \ ArsenalTables.php中给出
我有一个非常相似的查询,实际上它与不同的变量名相同,但我无法理解为什么这不起作用?
$customtable_query = "SELECT * FROM `arsenaltable`\n" . "ORDER BY `arsenaltable`.`points` DESC LIMIT 0, 30 ";
$customtable_result = mysql_query($customtable_query);
while ($customtable_row = mysql_fetch_assoc($customtable_result))
{
$played = $customtable_row['played'];
echo $played;
}
答案 0 :(得分:1)
删除换行符
$customtable_query = "SELECT * FROM arsenaltable ORDER BY arsenaltable,points DESC LIMIT 0, 30 ";
$customtable_result = mysql_query($customtable_query);
while ($customtable_row = mysql_fetch_assoc($customtable_result)) {
$played = $customtable_row['played'];
echo $played;
}
希望这有帮助!
答案 1 :(得分:1)
您可能希望查看mysql_error()的特定错误。 你的mysql_query()调用返回false,这就是为什么错误说mysql_fetch_assoc()中的参数是一个布尔值。
答案 2 :(得分:0)
还传递mysql_query中的连接变量。希望这会有所帮助。
$con=mysql_connect("localhost", "root","password");
$customtable_query = "SELECT * FROM `arsenaltable`\n" . "ORDER BY `arsenaltable`.`points` DESC LIMIT 0, 30 ";
$customtable_result = mysql_query($customtable_query,$con);
while ($customtable_row = mysql_fetch_assoc($customtable_result))
{
$played = $customtable_row['played'];
echo $played;
}