Please help

shlay

Joined: 2003-06-25
Posts: 11
Posted: Sat, 2003-06-28 05:54

I'm at my wits end with this block-random.php stuff. I was working with pskang to try and figure this out. He was having problems making the block-random work, too. We both did the exact same thing, yet his works and mine doesn't. I have a test page that you can see the source that I'm doing and the error I get.

http://www.shaylaonline.com/random.html

The error I get is:

Warning: Invalid argument supplied for foreach() in /web/home/shlay/shaylaonline.com/gallery/block-random.php on line 239
No photo chosen.

I don't know much about PHP, but I decided to check to see what was on line 239 in the code:

function chooseAlbum() {
global $cache;

/*
* The odds that an album will be selected is proportional
* to the number of (visible) items in the album.
*/

$total = 0;
foreach ($cache as $name => $count) { <-- line 239
if (!$choose) {
$choose = $name;
}

See all the block-random.php code here: http://www.shaylaonline.com/gallery/block-random.phps

I'm stuck because I have no clue what this piece of code is supposed to be doing.

Thanks in advance!

-Shayla

 
shlay

Joined: 2003-06-25
Posts: 11
Posted: Sat, 2003-06-28 06:03
shlay wrote:
I'm at my wits end with this block-random.php stuff. I was working with pskang to try and figure this out. He was having problems making the block-random work, too. We both did the exact same thing, yet his works and mine doesn't. I have a test page that you can see the source that I'm doing and the error I get.

http://www.shaylaonline.com/random.html

The error I get is:

Warning: Invalid argument supplied for foreach() in /web/home/shlay/shaylaonline.com/gallery/block-random.php on line 239
No photo chosen.

I don't know much about PHP, but I decided to check to see what was on line 239 in the code:

function chooseAlbum() {
global $cache;

/*
* The odds that an album will be selected is proportional
* to the number of (visible) items in the album.
*/

$total = 0;
foreach ($cache as $name => $count) { <-- line 239
if (!$choose) {
$choose = $name;
}

See all the block-random.php code here: http://www.shaylaonline.com/gallery/block-random.phps

I'm stuck because I have no clue what this piece of code is supposed to be doing.

Thanks in advance!

-Shayla

I think I fixed it. I went ahead and just deleted the block-random.cache file in my /albums directory. It was 0 length, so what could it hurt, right? Well, I deleted it, refreshed my page, and voila! Random picture! I think I'll be able to sleep better tonight. ;) On tap for tomorrow, how to get the block-random.php script to only select from certain albums - if its possible!

G'nite!