8Warning: rand() expects parameter 2 to be long, string given in /home/virtual/site11/fst/var/www/html/gallery/block-random.php on line 138
ERROR: requested index [] out of bounds [7]
in /home/virtual/site11/fst/var/www/html/gallery/classes/Album.php on line 570
8Warning: rand() expects parameter 2 to be long, string given in /home/virtual/site11/fst/var/www/html/gallery/block-random.php on line 138
Posts: 5
I have the same problem now actually - after a php upgrade to 4.2.2
Posts: 5
ooo elsewhere on this forum - http://gallery.menalto.com/modules.php?op=modload&name=phpBB_14&file=index&action=viewtopic&topic=191&4 to be precise :smile: is THE answer - thank you eilko soooooo much for that!
here's what worked - [quoting eilko]
change the readCache() function in the block_random.php
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
function readCache() {
global $cache;
if ($fd = fs_fopen(CACHE_FILE, "r")) {
while ($line = fgets($fd, 4096)) {
list($key, $val) = explode("/", trim($line));
$cache[$key] = $val;
}
fclose($fd);
}
}
</TD></TR></TABLE><!-- BBCode End -->
I did it and it worked like a charm, though hehe I still get a bloated Guest count but so what.. its working! Thank you again folks!
and thanks for putting in this forum! :smile:
- Suede
Posts: 4
I had the same problem. It seems that the $count variable is typed as a string instead of a number. I just added 0 to it before the rand function, and voila:
function choosePhoto($album) {
global $cache;
$count = $cache[$album->fields["name"]];
$count += 0;
if ($count == 0) {
// Shouldn't happen
return null;
} else if ($count == 1) {
$choose = 1;
} else {
$choose = rand(1, $count);
$wrap = 0;
if ($album->isHidden($choose)) {
$choose++;
if ($choose > $album->numPhotos(1)) {
$choose = 1;
$wrap++;
if ($wrap = 2) {
return null;
}
}
}
}
return $choose;
}