可能重复:
PHP Error: mysql_fetch_array() expects parameter 1 to be resource, boolean given
我已经检查了两次代码并且我也检查了表中的标题并且它们匹配,我可能已经查看代码的时间太长而且我可能很难找到错误。
第13-34行
$albums_query = mysql_query("
SELECT `albums`.`album_id`, `albums`.`timestamp`, `albums`.`name`, LEFT(`albums`.`description`, 50) as `description`, COUNT (`images`.`images_id`) as `image_count`
FROM `albums`
LEFT JOIN `images`
ON `albums`.`album_id` = `images`.`album_id`
WHERE `albums`.`user_id` = ".$_SESSION['user_id']."
GROUP BY `albums`.`album_id`
");
while ($albums_query = mysql_fetch_assoc($albums_query)) {
$albums[] = array(
'id' => $albums_row['album_id'],
'timestamp' => $albums_row['timestamp'],
'name' => $albums_row['name'],
'description' => $albums_row['description'],
'count' => $albums_row['image_count']
);
}
return $albums ;
}
答案 0 :(得分:2)
您使用一行数据覆盖查询结果:
$albums_query = mysql_fetch_assoc($albums_query)
应该是:
$albums_row = mysql_fetch_assoc($albums_query)
(可能)