random picture problem random picture problem
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

random picture problem

Started by purple, March 05, 2004, 05:38:45 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

purple

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

purple

go to the bottom and hit F5 a few times - whether or not the random images apprear seems random itself :).

Casper

It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

purple

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

ipas

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