Author Topic: Picture of the month  (Read 152072 times)

0 Members and 1 Guest are viewing this topic.

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: Picture of the month
« Reply #90 on: August 30, 2006, 03:12:01 PM »
ok.. here are a simply way to do that! is my alternative code.. sorry for confusing php code parts.. but it works!

step 1:
 :arrow:
find in include/pages_header.php
Code: [Select]
//-----------------------------------------------------
//--- Random Image ------------------------------------
//-----------------------------------------------------

insert above:
Code: [Select]
$random_image_3 = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "" : get_random_image();
$site_template->register_vars("random_image_3", $random_image_3);
unset($random_image_3);
step 2:
 :arrow:
in index.php find:
Code: [Select]
$site_template->register_vars("new_images", $new_images);
unset($new_images);
insert after:
Code: [Select]
//------------------------------------
//------- Random Images_3 --------------
//------------------------------------

$sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_thumb_file, i.image_media_file, i.image_thumb_file, i.image_rating, i.image_votes, i.image_comments, c.cat_name, u.user_name, i.image_downloads, i.image_hits, i.image_potm, i.image_potm_date, i.image_potm_votes
       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 = i.image_potm AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
        ORDER BY  i.image_potm_date DESC
        LIMIT 1";
     // end new
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
$random_images_3 = "";
$random_images_3 .= "</td></tr></table>";
}
else  {
$random_images_3 = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
$count = 1;
$bgcounter = 1;
while ($image_row = $site_db->fetch_array($result)){
   if ($count == 0) {
     $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
     $random_images_3 .= "<tr class=\"imagerow".$row_bg_number."\">\n";
   }
   $random_images_3 .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

   show_image($image_row);
   $random_images_3 .= $site_template->parse_template("thumbnail_bit_potm"); // original code

   $random_images_3 .= "\n</td>\n";
   $count++;
   if ($count == $config['image_cells']) {
     $random_images_3 .= "</tr>\n";
     $count = 0;
   }
} // end while

if ($count > 0)  {
   $leftover = ($config['image_cells'] - $count);
   if ($leftover >= 1) {
     for ($f = 0; $f < $leftover; $f++) {
       $random_images_3 .= "";
     }
     $random_images_3 .= "";
   }
}
$random_images_3 .= "</table>\n";
} // end else


$site_template->register_vars("random_images_3", $random_images_3);
unset($random_images_3);

//----- End Random Images_3---------
step 3:
 :arrow:
you made a new template in template/default: thumbnail_bit_potm :
Code: [Select]
<div align="center">{thumbnail}<br>
  <b>{image_name}</b> {if image_is_new}<sup class="new">{lang_new}</sup>{endif image_is_new} {if image_is_potm} <sup class="new">{lang_potm}</sup> {endif image_is_potm}</div>
step 4:
 :arrow:
in user_logininfo.html/user_loginform.html or home.html insert this:
Code: [Select]
{random_images_3}
i hope it works...
« Last Edit: September 09, 2006, 04:42:48 PM by Loda »

Offline HorrorCrafT

  • Full Member
  • ***
  • Posts: 106
    • View Profile
    • HYPOfun online
Re: Picture of the month
« Reply #91 on: August 30, 2006, 03:48:35 PM »
hey, thank you very much! i test the code and give feedback to you - my wonderful english i know  :D :D

in deutsch würde es besser gehen - ich bedanke mich recht herzlich und werde den code heute abend einbauen. so richtig testen kann ich ihn allerdings erst ab 1. september da mein "picture of the month" erst seit ca. einer woche läuft und es deshalb noch kein bild des monats für die anzeige gibt.

danke dir für deine mühe!!

Offline HorrorCrafT

  • Full Member
  • ***
  • Posts: 106
    • View Profile
    • HYPOfun online
Re: Picture of the month
« Reply #92 on: September 01, 2006, 12:45:28 AM »
hello Loda!

now, i have tested your code an get this error:

Code: [Select]
Warning: implode() [function.implode]: Bad arguments. in /is/htdocs/wp1008189_Y0VAU6S438/www.hypofun.com/pixgalerie/index.php on line 158

DB Error: Bad SQL Query: SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_thumb_file, i.image_media_file, i.image_thumb_file, i.image_rating, i.image_votes, i.image_comments, c.cat_name, u.user_name, i.image_downloads, i.image_hits, i.image_potm, i.image_potm_date, i.image_potm_votes FROM 4imagesimages i, 4imagescategories c LEFT JOIN 4imagesusers u ON (u.user_id = i.user_id) WHERE i.image_active = i.image_potm AND c.cat_id = i.cat_id AND i.cat_id IN (0, 37, 44, 47, 50, 55, 32, 22, 14, 18, 20, 38, 60, 54, 25, 43, 23, 17, 7, 26, 46, 33, 42, 40, 15, 59, 53, 12, 24, 13, 16, 45, 27, 34, 41, 57, 49, 19, 35, 6, 56, 48, 28, 21, 52, 36, 29, 51, 30, 8, 9, 31, 10, 11) AND i.cat_id IN () ORDER BY i.image_potm_date DESC LIMIT 1
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 ') ORDER BY i.image_potm_date DESC LIMIT 1' at line 4

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /is/htdocs/wp1008189_Y0VAU6S438/www.hypofun.com/pixgalerie/includes/db_mysql.php on line 116

do you have an idea what's wrong? :D

thanks for your help!!

here is my index and page_header.php:

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: Picture of the month
« Reply #93 on: September 01, 2006, 07:14:28 AM »
i think you have mysql version 5?
than you have to insert (  )
change step 2 with this:
 :arrow:
Code: [Select]
//------------------------------------
//------- Random Images_3 --------------
//------------------------------------

$sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_thumb_file, i.image_media_file, i.image_thumb_file, i.image_rating, i.image_votes, i.image_comments, c.cat_name, u.user_name, i.image_downloads, i.image_hits, i.image_potm, i.image_potm_date, i.image_potm_votes
       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 = i.image_potm AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").") AND i.cat_id IN (".implode(", ", $cat_in).")
        ORDER BY  i.image_potm_date DESC
        LIMIT 1";
     // end new
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
  $new_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
 $new_images .= "</td></tr></table>";
}
else  {
$random_images_3 = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
$count = 1;
$bgcounter = 1;
while ($image_row = $site_db->fetch_array($result)){
   if ($count == 0) {
     $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
     $random_images_3 .= "<tr class=\"imagerow".$row_bg_number."\">\n";
   }
   $random_images_3 .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

   show_image($image_row);
   $random_images_3 .= $site_template->parse_template("thumbnail_bit_potm"); // original code

   $random_images_3 .= "\n</td>\n";
   $count++;
   if ($count == $config['image_cells']) {
     $random_images_3 .= "</tr>\n";
     $count = 0;
   }
} // end while

if ($count > 0)  {
   $leftover = ($config['image_cells'] - $count);
   if ($leftover >= 1) {
     for ($f = 0; $f < $leftover; $f++) {
       $random_images_3 .= "";
     }
     $random_images_3 .= "";
   }
}
$random_images_3 .= "</table>\n";
} // end else


$site_template->register_vars("random_images_3", $random_images_3);
unset($random_images_3);

//----- End Random Images_3---------
« Last Edit: September 01, 2006, 10:10:59 AM by Loda »

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: Picture of the month
« Reply #94 on: September 01, 2006, 08:14:06 AM »
and what show the last month winner at main page ???

 :wink:

Offline HorrorCrafT

  • Full Member
  • ***
  • Posts: 106
    • View Profile
    • HYPOfun online
Re: Picture of the month
« Reply #95 on: September 01, 2006, 09:54:53 AM »

hmmm, my statistic say i use mysql 4.1.15 and php 5.1.5
i check your changes after weekend. i'm now in italy for 3 days :D

thanks for your help again!! :D

@Stoleti:

with {random_images_3} you can show last winner pic on mainpage (insert this code in home.html - see also Loda changelog posting)

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: Picture of the month
« Reply #96 on: September 01, 2006, 12:48:51 PM »
also bei mir geht es.
@HorrorCrafT : vielleicht bastelst du ein wenig mit step zwei mal rum.. ich habe es nochmals im letzten posting geupdatet. es liegt bei dir wohl an der "if (!$num_rows)  {" bla bla sache...

Offline HorrorCrafT

  • Full Member
  • ***
  • Posts: 106
    • View Profile
    • HYPOfun online
Re: Picture of the month
« Reply #97 on: September 01, 2006, 01:11:33 PM »
okay, danke für die info! ich probier's mal mit der klammer und wenn das auch nicht geht dann meld ich mich nochmals. leider bin ich in php zu wenig fitt als dass ich da im code wild selber rumbasteln könnte. kleinigkeiten check ich ja noch aber sobald ich irgendwelche tabellenzugriffe auf die mysql datenbank anpassen muss, reicht mein wissen nicht mehr aus. in der von dir genannten zeile bräucht ich dann halt nochmals hilfe von dir. würde es gerne noch heute testen, geht sich aber leider nicht mehr aus. ich melde mich montag oder dienstag wieder.

ist nett, dass mir weiterhilfst, danke!

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: Picture of the month
« Reply #98 on: September 05, 2006, 04:27:52 AM »
Warning: implode(): Bad arguments. in /home2/****/public_html/index.php on line 216

DB Error: Bad SQL Query: SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_thumb_file, i.image_media_file, i.image_thumb_file, i.image_rating, i.image_votes, i.image_comments, c.cat_name, u.user_name, i.image_downloads, i.image_hits, i.image_potm, i.image_potm_date, i.image_potm_votes FROM (4images_images i, 4images_categories c) LEFT JOIN 4images_users u ON (u.user_id = i.user_id) WHERE i.image_active = i.image_potm AND c.cat_id = i.cat_id AND i.cat_id IN (0, 1, 9, 35) AND i.cat_id IN () ORDER BY i.image_potm_date DESC LIMIT 1
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 ') ORDER BY i.image_potm_date DESC LIMIT 1' at line 4

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/****/public_html/includes/db_mysql.php on line 116


Both codes for MySQL 4.XX or for MySQL 5 , give me this error at index.php

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: Picture of the month
« Reply #99 on: September 05, 2006, 06:17:50 AM »
1) please use BBCode when quote something
2) and on line 216 in index.php is...it should be the obvious first thing one should look at when see any error messages...
3) I dont see anything in the instructions about modifications in index.php
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 HorrorCrafT

  • Full Member
  • ***
  • Posts: 106
    • View Profile
    • HYPOfun online
Re: Picture of the month
« Reply #100 on: September 05, 2006, 11:20:34 PM »
Loda, ich hab es nun nochmals versucht, leider ohne erfolg. es kommt die selbe fehlermeldung wie oben gepostet :cry:

also bei mir ist es die zeile 158 in der index.php:
Code: [Select]
WHERE i.image_active = i.image_potm AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").") AND i.cat_id IN (".implode(", ", $cat_in).")die offenbar probleme macht (siehe fehlermeldung oben). leider hab ich keine ahnung wie so ein sql aufruf funktioniert, deshalb kann ich da überhaupt nichts umschreiben. hast du vielleicht noch eine idee? an den klammern liegt es jedenfalls nicht, es muss offenbar ein fehler in dieser zeile geben?

ich habe in der index.php einen weiteren sql aufruf der schon immer drinn war und auch funktioniert:
Code: [Select]
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, 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".$additional_sql.", 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 c.cat_id = i.cat_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
        ORDER BY i.image_date DESC
        LIMIT $num_new_images";
der grundsätzliche sql aufruf deiner modifikation ist also korrekt und erhärtet die annahme dass lediglich in der zeile 158 was nicht stimmt.

V@no, i don't understand your point 3. it's needful to modification the index.php! you are also a php guru - any idea what's wrong? :D

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: Picture of the month
« Reply #101 on: September 06, 2006, 12:37:45 AM »
V@no, i don't understand your point 3. it's needful to modification the index.php! you are also a php guru - any idea what's wrong? :D
Where does it say anything about index.php? I dont see it in the instructions from http://www.dignado.de/MOD_potm.zip package.
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 HorrorCrafT

  • Full Member
  • ***
  • Posts: 106
    • View Profile
    • HYPOfun online
Re: Picture of the month
« Reply #102 on: September 06, 2006, 01:08:59 AM »
V@no you are right but we have a discussion how can i see the last "picture of the month" winner on home.html (under random image) - this addon is not in the official MOD but a nice extension :D

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: Picture of the month
« Reply #103 on: September 06, 2006, 02:05:03 PM »
hallo!
@ horrorcraft: dann tausche deine zeile doch mal gegen dieses aus:
Code: [Select]
WHERE i.image_active = i.image_potm

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: Picture of the month
« Reply #104 on: September 06, 2006, 02:19:12 PM »
V@no you are right but we have a discussion how can i see the last "picture of the month" winner on home.html (under random image) - this addon is not in the official MOD but a nice extension :D
Oh, I see...I guess Loda either has some other code that generates a $cat_in array, or they forget add that part in their tutorial...there is no such variable as $cat_in in the default index.php - thats the problem...
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)