Jump to content


foreach() error is php5 causing this?

  • Please log in to reply
2 replies to this topic

#1 gupster

  • Members
  • PipPip
  • Member
  • 10 posts

Posted 11 September 2006 - 02:49 AM

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

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,


#2 trq

  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 11 September 2006 - 03:43 AM

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.

#3 jefkin

  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 11 September 2006 - 04:32 AM

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

if ($myCond)
    $myArray = somefunc();

foreach ($myArray as $elem)
    // ....

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

$myArray = array();

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


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users