Post by magzen » Fri Aug 28, 2015 6:42 am

Hello,

I moved my Opencart from localhost to live and are recieiving the following error on the frontpage

Code: Select all

Warning: Invalid argument supplied for foreach() in /home/www/domain.com/vqmod/vqcache/vq2-catalog_view_theme_journal2_template_common_header.tpl on line 156
I checked the header.tpl in the Journal template but it didnt tell me much about the problem.

If someone knows why iam recieving this error?

/magzen
Last edited by magzen on Fri Aug 28, 2015 9:37 pm, edited 2 times in total.

My Opencart Stores
http://www.crea-diem.com
http://www.bazaargadgets.com


Active Member

Posts

Joined
Tue Jun 05, 2012 7:04 pm


Post by straightlight » Fri Aug 28, 2015 7:30 am

Journal theme is a contributed template developed by an author aside the core. You would need to contact the author of the contribution to see what might be the source of the problem that is originating from VQMod. An additional solution, in this case, would be to switch to the default template and see if you notice the same type of problem.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by magzen » Fri Aug 28, 2015 9:23 pm

straightlight wrote:Journal theme is a contributed template developed by an author aside the core. You would need to contact the author of the contribution to see what might be the source of the problem that is originating from VQMod. An additional solution, in this case, would be to switch to the default template and see if you notice the same type of problem.

Thanks for your reply, i switched to the default template and the problem still exists but on a different line

Code: Select all

Warning: Invalid argument supplied for foreach() in /home/www/domain.com/vqmod/vqcache/vq2-system_modification_catalog_view_theme_default_template_common_header.tpl on line 95

My Opencart Stores
http://www.crea-diem.com
http://www.bazaargadgets.com


Active Member

Posts

Joined
Tue Jun 05, 2012 7:04 pm


Post by straightlight » Fri Aug 28, 2015 9:53 pm

Either the same or different XML file affects your site whether you switch from custom theme back to default or vice-versa. However, the provided error is still about a VQMod contribution that needs to be reported to the author that developed this.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Kenberne1965 » Fri Aug 28, 2015 9:55 pm

Hi, this generally means your trying to access an array in a foreach loop when the variable doesn't contain an array.

If you havn't already i would make sure you are running a clean vqmod install by clearing your vqmod cache and then if it still does this, you need to check the array that you are trying to access.

A good way to debug is to write out a $variable or $array to the error log in the controller for the view file, ie the header.php controller file like this

Code: Select all

$this->log->write($array);
then open up the error log and see what got output, I like to clear the log before i do this so its easier to find incase you have other errors in there.

or you can kill the script and view the $array after its been set with :-

Code: Select all

<?php print_r($array);
die('breakpoint'); ?>
this will give you a nice white page with just the arrray contents, If the array is empty which it sounds like it is, then you need to figure out why, also check the vqmod logs for clues too

Hope that Helps
Paul

Freelance Opencart 1.5.x and 2.x Developer - Available For Hire
Latest Opencart 2 Project --> http://www.falcon-rangecookers.co.uk


User avatar
Active Member

Posts

Joined
Wed Apr 22, 2015 9:37 pm
Location - Doncaster, UK

Post by straightlight » Fri Aug 28, 2015 10:13 pm

Kenberne1965 wrote:Hi, this generally means your trying to access an array in a foreach loop when the variable doesn't contain an array.

If you havn't already i would make sure you are running a clean vqmod install by clearing your vqmod cache and then if it still does this, you need to check the array that you are trying to access.

A good way to debug is to write out a $variable or $array to the error log in the controller for the view file, ie the header.php controller file like this

Code: Select all

$this->log->write($array);
then open up the error log and see what got output, I like to clear the log before i do this so its easier to find incase you have other errors in there.

or you can kill the script and view the $array after its been set with :-

Code: Select all

<?php print_r($array);
die('breakpoint'); ?>
this will give you a nice white page with just the arrray contents, If the array is empty which it sounds like it is, then you need to figure out why, also check the vqmod logs for clues too

Hope that Helps
Paul
Writing an array to a text / log file will simply display the Array word in the file. If you wish to test an array in a text file, the easiest way is by knowing the size, such as:

Code: Select all

$log = new Log('my_log.log');

$log->write(sizeof($array));

As for print_r to display, that is not entirely true. The display errors settings might be disabled as the user may only see a white page period.

Code: Select all


if (!empty($this->session->data['token'])) {
    ini_set('display_errors', true);

    error_reporting(E_ALL);

    echo "<pre />\n";
    print_r($array);
    echo "</pre>\n";

    exit;
}
Besides, OC admin settings already has an option to enable error display on screen.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Kenberne1965 » Fri Aug 28, 2015 10:42 pm

straightlight wrote:
Besides, OC admin settings already has an option to enable error display on screen.
1) he can already see errors, so your code is pointless (again)

2) im NOT outputting an error with print_r , if the array is empty it will just out put 'array( ) ' to the screen, regardless of whether he has errors on or off. ::)

Freelance Opencart 1.5.x and 2.x Developer - Available For Hire
Latest Opencart 2 Project --> http://www.falcon-rangecookers.co.uk


User avatar
Active Member

Posts

Joined
Wed Apr 22, 2015 9:37 pm
Location - Doncaster, UK

Post by straightlight » Fri Aug 28, 2015 10:50 pm

Kenberne1965 wrote:
straightlight wrote:
Besides, OC admin settings already has an option to enable error display on screen.
1) he can already see errors, so your code is pointless (again)

2) im NOT outputting an error with print_r , if the array is empty it will just out put 'array( ) ' to the screen, regardless of whether he has errors on or off. ::)
While he may or may not be able to see errors, it does not provide the right example to the next users who might encounter similar cases as they might not be able to see the results as this poster. Again, your post above is an incomplete statement.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Kenberne1965 » Fri Aug 28, 2015 10:57 pm

your not getting it.....

I showed the OP and any other people how to test an array, regardless of whether error reporting is on or off so NO your wrong (again).

I think your stalking me..... haha

heres an idea, why don't you go find a post where someone needs help, and actually help someone.

can i get a retraining order.. :laugh:

Freelance Opencart 1.5.x and 2.x Developer - Available For Hire
Latest Opencart 2 Project --> http://www.falcon-rangecookers.co.uk


User avatar
Active Member

Posts

Joined
Wed Apr 22, 2015 9:37 pm
Location - Doncaster, UK

Post by straightlight » Fri Aug 28, 2015 11:00 pm

I showed the OP and any other people how to test an array
And was done to a way that is not helping since outputting an array without extraction to a file will simply display the word Array. I will not ask you how would that approach would actually help someone since the type of response you're providing is just useless to respond period.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by magzen » Sun Aug 30, 2015 10:44 pm

Thanks for all the replies, got an answer from the Journal2 dev that the problem is from the file "_seo_mega_pack_extras.xml", when disabled that removed the error message, so have contacted the dev for the module to see why the following issue showing up, also noticed another issue in the same module multilingual pages doesnt work "Page does not exist", more issues than i knew about :-\

My Opencart Stores
http://www.crea-diem.com
http://www.bazaargadgets.com


Active Member

Posts

Joined
Tue Jun 05, 2012 7:04 pm

Who is online

Users browsing this forum: No registered users and 31 guests