Weird Error

3 posts by 2 authors in: Forums > CMS Builder
Last Post: June 22, 2015   (RSS)

I am using CMSB 2.64 and the error log is generating the following warning:

E_WARNING: Invalid argument supplied for foreach()/home/xxxxx/public_html/minutes_e.php (line 58)
http://xxxxx.ca/minutes_e.php/photo/photo/activities_e.php?Marksmanship-6

What doesn't make sense to me is the the files minutes_e.php and activities_e.php are separate files in the /public_html/ folder.  Here is the file structure:

/public_html/ {all website files located here}
     /photo/  {4Images open source software located here}
     /cmsb/
     etc....

There is no .../photo/photo/activities_e.php.  activities_e.php only resides in /public_html/, so I don't understanding how this even works!

Confused!

--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

By Dave - June 22, 2015

Hi Ragi, 

This error: "E_WARNING: Invalid argument supplied for foreach() ..." usually means the $records array is empty.  You can either wrap for foreach in an if block like this:

if ($records) { 
  foreach ($records as $record) { 
    ...
  }
}

Or you could try forcing $records to be an array by adding (array) in front to force (type cast) it into an array.  Test and make sure that works before sticking with it:

foreach ((array) $records as $record) { 
  ...
}

Or just exit at the top of the page or display an error if no records are found.

And for the URL in the error log entry... The error log functions try to guess the current url.  It could be wrong, or the one file could be including the other, or something else interesting.  The url does start with /minutes_e.php/ ... You could try this url and see if it works: http://insert_your_domain/minutes_e.php/photo/photo/activities_e.php?Marksmanship-6  In any case, those are two unrelated issues.  One is the foreach loop gets called even when the record array is empty, and the other is the either an unexpected URL is being accessed and/or the url is being logged incorrectly.

Hope that helps! Let me know any questions.

Dave Edis - Senior Developer
interactivetools.com