Jump to content

Archived

This topic is now archived and is closed to further replies.

gupster

foreach() error is php5 causing this?

Recommended Posts

Ive installed some php software and ime getting this error [code]Warning: Invalid argument supplied for foreach() in D:\reactionvision.co.uk\wwwroot\components\com_flickr4j\flickr4j.html.php on line 295[/code]

I may be very very wrong but i am using php 5 on my server is it caused that the program was maybe written for php 4. Im not 100% sure but thats my only guess as you can tell i know very little a bout php. Is there a way to fix this?

Many thanks,

Adam
[url=http://www.reactionvision.co.uk]www.reactionvision.co.uk[/url]

Share this post


Link to post
Share on other sites
It is not an error on php5's part. its more than likely your code. We need to see some of which before we could possibly help.

Share this post


Link to post
Share on other sites
I've seen this error many times.

It means that the variable you sent to the foreach isn't an array.

This can usually be fixed by changing code like

[code]
if ($myCond)
{
    $myArray = somefunc();
}

foreach ($myArray as $elem)
{
    // ....
}
[/code]

into code with a preset default for the var (an empty array).

[code]
$myArray = array();
[/code]

Trust me on this, that eror only occurs when some path to your foreach doesn't let the variable become an array.

Jeff

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.