gupster Posted September 11, 2006 Share Posted September 11, 2006 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] Link to comment https://forums.phpfreaks.com/topic/20341-foreach-error-is-php5-causing-this/ Share on other sites More sharing options...
trq Posted September 11, 2006 Share Posted September 11, 2006 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. Link to comment https://forums.phpfreaks.com/topic/20341-foreach-error-is-php5-causing-this/#findComment-89609 Share on other sites More sharing options...
jefkin Posted September 11, 2006 Share Posted September 11, 2006 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 Link to comment https://forums.phpfreaks.com/topic/20341-foreach-error-is-php5-causing-this/#findComment-89624 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.