我有一个查询,它会提取用户收藏夹列表并在页面上显示图像。我想要做的是,如果没有要显示的收藏夹来显示文件目录中的模板图像。
我正在尝试这样做,但会出现此错误:
Warning: file_exists() expects parameter 1 to be string, resource given in /Applications/XAMPP/xamppfiles/htdocs/PTB1/includes/mod_favourites/favourites.php on line 28
Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in /Applications/XAMPP/xamppfiles/htdocs/PTB1/includes/mod_favourites/favourites.php on line 33
我下面的代码有人可以帮助我并向我展示如何做我想做的事情吗?
谢谢。
<?php
$favorites_set_more = get_user_favorites_more();
if (!file_exists($favorites_set_more)) {
$favorites_set_more = "data/photos/0/_default.jpg";
}
while ($favorites2 = mysql_fetch_array($favorites_set_more)) {
echo "<a href=\"profile.php?id={$favorites2['favorite_id']}\"><img width=\"90px\" height=\"90px\" class=\"favorites_pic2\" src=\"data/photos/{$favorites2['favorite_id']}/_default.jpg\" /></a>";
?>
<? } ?>
这是 favourites_set_more 函数:
function get_user_favorites_more() {
global $connection;
global $_SESSION;
$query = "SELECT f.favorite_id, p.display_name
FROM ptb_favorites f, ptb_profiles p
WHERE f.user_id =".$_SESSION['user_id']."
AND p.user_id = f.user_id
LIMIT 4,12";
$favorites_set_more = mysql_query($query, $connection);
confirm_query($favorites_set_more);
return $favorites_set_more;
}