This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

I am getting "invalid argument supplied for foreach()" warning
#1

Here is my situation.
I've integrated this wonderful module seamlessly on my local server.
When I moved it to the hosting site, I made a mistake and uploaded it into /commentics/upload/ folder. From there I did the install.
When I realized that this was not the place I wanted it to be, I moved all files (manually) to the /commentics/ folder. And I didn't do the new install.
Now things work seemingly OK, except that I am seeing a warning "invalid argument supplied for foreach() in /commentics/system/library/modification.php on line 32.
Even though it's just a warning I don't like it as it creates a new record every single time anyone accesses the frontend or the backend.
Might this error be related to me moving the files around manually? Can it be something in my server settings?
Anyone had a similar case?
Any ideas?
Thanks,
Mike
Reply
#2

Hi Mike,

Can you open /commentics/system/library/modification.php and above line 32 add:

PHP Code:
<?php 
var_dump
(CMTX_DIR_MOD_XML);

That will show you the path it's trying to use.

If you only want it to show for you, you could wrap it in an IP address check like this:

PHP Code:
<?php 
if ($_SERVER['REMOTE_ADDR'] == 'your_ip_address_here') {
var_dump(CMTX_DIR_MOD_XML);
}

If the path looks fine and it exists, can you try replacing:

PHP Code:
<?php 
foreach (glob(CMTX_DIR_MOD_XML . '*.xml') as $filename) {
$xmls[] = file_get_contents($filename);
}

With this:

PHP Code:
<?php 
$glob_files
= glob(CMTX_DIR_MOD_XML . '*.xml');
if (
is_array($glob_files) && count($glob_files) > 0) {
foreach (
$glob_files as $filename) {
$xmls[] = file_get_contents($filename);
}
}

If you could let me know the outcome that'd be great.

Have you completed the interview?
Reply
#3

Did both of the things you've suggested, Steven.
The error is gone!
Thanks a lot!
Mike
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Steven
17-Jan-2024, 09:53 PM
Last Post by goppss
06-Jan-2013, 10:26 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)