Difference between revisions of "Talk:Errors"

From Zen Cart(tm) Wiki
Jump to: navigation, search
(Warning: Variable passed to each() is not an array or object in ... includes/application_top.php on line 682)
Line 21: Line 21:
  
 
--[[User:Dwno|Dwno]] 15:08, 4 January 2006 (MST)
 
--[[User:Dwno|Dwno]] 15:08, 4 January 2006 (MST)
 +
 +
hi,
 +
 +
I have been working for the last couple of months with full error reporting turned on, in order to catch places where variables are not initilaised. I agree it is a bad thing (lots of stuff in legacy code, and new stuff as well)
 +
 +
However I think ther is a problem with the instructions
 +
 +
#Open includes/modules/product_listing.php
 +
## Replace <pre><nowiki>  if (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0 and $show_submit == 'true' and $listing_split->number_of_rows > 0) {
 +
    // bof: multiple products
 +
    $how_many = 0;
 +
    echo zen_draw_form('multiple_products_cart_quantity', zen_href_link(zen_get_info_page($_GET['products_id']), zen_get_all_get_params(array('action')) . 'action=multiple_products_add_product'), 'post', 'enctype="multipart/form-data"');
 +
  }</nowiki></pre>with<pre><nowiki>    $how_many = 0;</nowiki></pre>
 +
 +
 +
This suggest replacing the whole code block . should no the replacement be
 +
 +
<pre><nowiki>      $how_many = 0;
 +
  if (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0 and $show_submit == 'true' and $listing_split->number_of_rows > 0) {
 +
    // bof: multiple products
 +
    echo zen_draw_form('multiple_products_cart_quantity', zen_href_link(zen_get_info_page($_GET['products_id']), zen_get_all_get_params(array('action')) . 'action=multiple_products_add_product'), 'post', 'enctype="multipart/form-data"');
 +
  }</nowiki></pre</pre>

Revision as of 18:36, 7 January 2006

New page - comments?

I made this page to suggest that we need something like this.
Any suggestions regarding which category it fits best into, or perhaps how the page should be layed out?

Perhaps we need a "Troubleshooting" category too?

Warning: Variable passed to each() is not an array or object in ... includes/application_top.php on line 682

In case things are unclear, the suggested fix deals with 2 related bugs.

Step 1 and 3 deals with one bug, and step 2 deals with another.

$how_many is according to my suggested fix not enclosed within an if statement because as far as I can see there's no reason it shouldn't be initialised, and IMO it's not a good idea to use an unitialised variable. ;-)

The if statement and form output is moved to the bottom of the file, after $how_many has been created so we can see if we're supposed to draw the form or not. That was one bug.

The other bug was displaying "Add selected products to cart" buttons where they shouldn't be displayed. $how_many is now incremented only if the product can be added to cart from the "multiple add to cart"-form.

Hope that helps.

--Dwno 15:08, 4 January 2006 (MST)

hi,

I have been working for the last couple of months with full error reporting turned on, in order to catch places where variables are not initilaised. I agree it is a bad thing (lots of stuff in legacy code, and new stuff as well)

However I think ther is a problem with the instructions

  1. Open includes/modules/product_listing.php
    1. Replace
        if (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0 and $show_submit == 'true' and $listing_split->number_of_rows > 0) {
   // bof: multiple products
   $how_many = 0;
   echo zen_draw_form('multiple_products_cart_quantity', zen_href_link(zen_get_info_page($_GET['products_id']), zen_get_all_get_params(array('action')) . 'action=multiple_products_add_product'), 'post', 'enctype="multipart/form-data"');
}with
    $how_many = 0;


This suggest replacing the whole code block . should no the replacement be

      $how_many = 0;
   if (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0 and $show_submit == 'true' and $listing_split->number_of_rows > 0) {
    // bof: multiple products
    echo zen_draw_form('multiple_products_cart_quantity', zen_href_link(zen_get_info_page($_GET['products_id']), zen_get_all_get_params(array('action')) . 'action=multiple_products_add_product'), 'post', 'enctype="multipart/form-data"');
  }</pre