dongqi8114 2012-04-21 16:10
浏览 14

警告:mysql_fetch_assoc():提供的参数不是第22行/home/a5751969/public_html/func/album.func.php中的有效MySQL结果资源[重复]

Possible Duplicate:
PHP Error: mysql_fetch_array() expects parameter 1 to be resource, boolean given

I have checked the code twice and I have also checked the titles in the table also and they match, I have probably been looking at the code for too long and it may be hard for me to find the error.

Lines 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 ;

}

  • 写回答

1条回答 默认 最新

  • dtcrw26206 2012-04-21 16:12
    关注

    You're overriding your query result with a row of data:

    $albums_query = mysql_fetch_assoc($albums_query)
    

    Should be:

     $albums_row = mysql_fetch_assoc($albums_query)
    

    (probably)

    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)