coppermine-gallery.com/forum

Support => Older/other versions => cpg1.2 Standalone Support => Topic started by: purple on March 05, 2004, 05:38:45 PM

Title: random picture problem
Post by: purple on March 05, 2004, 05:38:45 PM
hello,

i just installed the latest version of coppermine this afternoon and added all my pictures. however my random picture section is not working (it seems to give something every once in a blue moon, but not consitently).

http://www.ultraworld.be/ben/images/index.php

is the url to the installation.

i get the persistent "No image to display" message.

thanks,

Ben
Title: random picture problem
Post by: purple on March 05, 2004, 06:17:20 PM
go to the bottom and hit F5 a few times - whether or not the random images apprear seems random itself :).
Title: random picture problem
Post by: Casper on March 05, 2004, 06:36:21 PM
Try this thread, http://forum.coppermine-gallery.net/index.php?topic=3661.
Title: random picture problem
Post by: purple on March 05, 2004, 07:02:58 PM
i also changed it to 5000 and it seems to work.

this is the relative piece of code from include/functions.inc.php:


if ($pic_count > 10000) {
 
  $result = db_query("SELECT COUNT(*) from {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES'");
  $nbEnr = mysql_fetch_array($result);
  $total_count = $nbEnr[0];
  mysql_free_result($result);

  $granularity = floor($total_count / RANDPOS_MAX_PIC);
  $cor_gran = ceil($total_count / $pic_count);
  srand(time());
  for ($i=1; $i<= $cor_gran; $i++) $random_num_set =rand(0, $granularity).', ';
  $random_num_set = substr($random_num_set,0, -2);
  $result = db_query("SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE  randpos IN ($random_num_set) AND approved = 'YES' $ALBUM_SET ORDER BY RAND() LIMIT $limit2");

} else {

  $result = db_query("SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' $ALBUM_SET ORDER BY RAND() LIMIT $limit2");

}


i'm not quire sure what, but something in the first part of the if-condition seems to fail most of the time.

any idea's ?

it works now i changed it to 5000 (since i only have about 2k pics), but it might help to know for future reference what the problem is :)

purps
Title: Re: random picture problem
Post by: ipas on May 23, 2004, 05:59:51 PM
Indeed.. I had the same problem. Somehow the random picture problem does not always accur. It looks like is happens when is random select one of the last inserted pictures.

I changed the value to 5000  and it looks like the problem is gone.. for now..

Grtz
Ipas