Author Topic: [SOLVED] All the images which the lenght of the Youtube Id different dan 11  (Read 3287 times)

0 Members and 1 Guest are viewing this topic.

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Hi,

I need help for this query.

I need all the images which the lenght of the Youtube Id different dan 11.

I used this query, but I get all the images.


Code: [Select]
$youtubeLEN = strlen($image_row['image_youtube']);

$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_speler, i.image_youtube, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, i.image_postcards".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email")."
        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 $youtubeLEN != '11' AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
GROUP BY i.image_name
ORDER BY i.image_date DESC

LIMIT 10
";

Can someone correct this query for me please?

Thanks in advanace,
« Last Edit: January 01, 2009, 01:53:29 PM by cruxy »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: All the images which the lenght of the Youtube Id different dan 11
« Reply #1 on: December 31, 2008, 02:02:06 AM »
Code: [Select]
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_speler, i.image_youtube, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, i.image_postcards".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email")."
        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 CHAR_LENGTH(i.image_youtube) <> 11 AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
GROUP BY i.image_name
ORDER BY i.image_date DESC

LIMIT 10
";

Should do it.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: All the images which the lenght of the Youtube Id different dan 11
« Reply #2 on: December 31, 2008, 02:19:29 AM »
Thanks V@no. It is working :D

PS: Nobody has used this code (CHAR_LENGTH) on this forum before.