i am not good in php, plz move this post to its proper section if it is not right here.
i tried to used the top downloaded images code
{lang_top_image_rating} {image_rating_1} n others on
home.html and added the below code of
top downloads to
index.php from
top.php// Downloads
$sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_downloads,
c.cat_name".get_user_table_field(", u.", "user_name")."
FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id
$cat_match_sql
ORDER BY i.image_downloads DESC, i.image_name ASC
LIMIT 10";
$result = $site_db->query($sql);
$top_list = array();
$i = 1;
while ($row = $site_db->fetch_array($result)) {
$top_list[$i] = $row;
$i++;
}
$site_db->free_result();
for ($i = 1; $i <= 10; $i++) {
if (isset($top_list[$i])) {
$register_array['image_downloads_'.$i] = (check_permission("auth_viewimage",
$top_list[$i]['cat_id'])) ? "<a
href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."
\">".format_text($top_list[$i]['image_name'])."</a>" :
format_text($top_list[$i]['image_name']);
$register_array['image_downloads_openwindow_'.$i] = (check_permission("auth_viewimage",
$top_list[$i]['cat_id'])) ? "<a
href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."
\" onclick=\"opendetailwindow()\"
target=\"detailwindow\">".format_text($top_list[$i]['image_name'])."</a>" :
format_text($top_list[$i]['image_name']);
if (isset($top_list[$i][$user_table_fields['user_name']]) && $top_list[$i]['user_id'] !=
GUEST) {
$user_profile_link = (!empty($url_show_profile)) ? preg_replace("/{user_id}/",
$top_list[$i]['user_id'], $url_show_profile) :
ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$top_list[$i]['user_id'];
$register_array['image_downloads_user_'.$i] = "<a
href=\"".$site_sess->url($user_profile_link)."\">".format_text($top_list[$i][$user_table_fields
['user_name']])."</a>";
}
else {
$register_array['image_downloads_user_'.$i] = $lang['userlevel_guest'];
}
$register_array['image_downloads_cat_'.$i] = "<a
href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$top_list[$i]['cat_id'])."\
">".format_text($top_list[$i]['cat_name'])."</a>";
$register_array['image_downloads_number_'.$i] =
"<b>".$top_list[$i]['image_downloads']."</b>";
}
else {
$register_array['image_downloads_'.$i] = "--";
$register_array['image_downloads_user_'.$i] = "--";
$register_array['image_downloads_cat_'.$i] = "--";
$register_array['image_downloads_number_'.$i] = "--";
}
}
$site_template->register_vars($register_array);
//-----------------------------------------------------
but i am getting this error.
DB Error: Bad SQL Query: SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_downloads, c.cat_name, u.user_name FROM (4images_images i, 4images_categories c) LEFT JOIN 4images_users u ON (u.user_id = i.user_id) WHERE i.image_active = 1 AND i.cat_id NOT IN () AND i.cat_id = c.cat_id ORDER BY i.image_downloads DESC, i.image_name ASC LIMIT 10
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND i.cat_id = c.cat_id ORDER BY i.image_downloads DESC, i.' at line 4
how to remove this error
help needed plz anyone