Warning: rand() expects parameter 2 to be long...

slowmail

Joined: 2002-09-13
Posts: 4
Posted: Thu, 2003-04-03 15:25

Could anyone shed some light why I'm seeing this error?

Warning: rand() expects parameter 2 to be long, string given in /home/user/lib/gallery-1.3.3/block-random.php on line 138
ERROR: requested index [] out of bounds [97]
Fatal error: Call to a member function on a non-object in /home/user/lib/gallery-1.3.3/classes/Album.php on line 642

http://photos.mydomain.com/block-random.php showed a random image ONCE, and now it gives me that error.

Advice anyone?

No idea if it's revelant, but:

subdomain photos resolves under /public_html/photos
photos is a symbolic link to ../../lib/gallery-1.3.3

Everything else works well.

*scratch head*

 
darkknight
darkknight's picture

Joined: 2003-03-01
Posts: 40
Posted: Sat, 2003-04-05 22:31

Thats exactly what i get as well... and i dont know why either... (im running standalone)

 
10k
10k's picture

Joined: 2003-04-19
Posts: 1
Posted: Sat, 2003-04-19 22:52

I get the exact same thing. Showed a picture once, then got that error. Does anyone have any info on this? I'm running it as a stand alone. I have messages boards, etc, but I'm not trying to embed anything. I just want a random photo on my homepage. Thanks :smile:

 
hawkin
hawkin's picture

Joined: 2002-08-15
Posts: 45
Posted: Thu, 2003-05-01 02:25

I get the same error.
and this appeared after we upgraded php from 4.1.2 to 4.3.1 (also apache2 and mysql4, but I dun think that should have anything to do with gallery)
Could the new version of php be the problem?

I will look into the random file and see if changing the rand() function will help..

 
hawkin
hawkin's picture

Joined: 2002-08-15
Posts: 45
Posted: Thu, 2003-05-01 02:48

I think I fixed it.
I am not sure, but it seems it could be a bug in php 4.3.1 (and maybe other earlier version, I dunno...) that was not aparent in php 4.1.2

I put in this at line 141:
$count = floatval($count);

in front of:
$choose = rand(1, $count);

That seems to solve the problem (makes sure the count variable is a float variable, witch is what php complains about)

 
sotranow

Joined: 2003-04-02
Posts: 3
Posted: Tue, 2003-12-02 21:10

:wink:
thanks, this fixed my problem
php 4.32
gallery 1.4.1
block-NG-RandomImproved

 
RhythmAce

Joined: 2002-12-01
Posts: 4
Posted: Thu, 2003-12-04 02:09

"The gift that keeps on giving" It fixed my problem too with gallery 1.4.1 running on phpnuke 6.9

 
kanaha

Joined: 2003-09-09
Posts: 5
Posted: Fri, 2004-01-23 22:53

Thank you thank you thank you!!

This is just the fix I needed!