Forums / General Questions / WARNING: An Error occurred, please refresh the page and try again

WARNING: An Error occurred, please refresh the page and try again

Views: 4,338

Results 1 to 4 of 4
16 Aug 2016, 2:55 PM
#1
riomaha avatar

riomaha

New Zenner

Join Date:
Oct 2013
Location:
MTL
Posts:
66
Plugin Contributions:
1

WARNING: An Error occurred, please refresh the page and try again

I find myself at loss again. Possibly, I am not thinking straight for two days. Here is my issue of the week:
I have three teams each team looks after specific product/product category. So when an order comes in for product (e.g. Running Shoes) or category Shoes, team Footwear will filter the orders page (on admin side) to view orders that pertains to footwear or a running shoes and can filter based on rush order or not.

I had a simple hard coded filters in version 1.5.1 that was working but it doesn't work well into 1.5.5

Below is a snippet of the select statement. What you don't see is that I have a drop down box that is defined earlier in the page to define the priority and category example
Footwear - Rush Orders
Footwear - Regular Orders

($_GET['priority'] == 'ot_priority_handling_categoryX1') {
      $priority = zen_db_prepare_input($_GET['priority']);
      $orders_query_raw = "select o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.shipping_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, 'See Order Details' as order_total" .
                          $new_fields . "
                          from (" . TABLE_ORDERS_STATUS . " s, " .
			  TABLE_ORDERS . " o " .
                          $new_table . ")
                          left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id)" . "
			  left join " . TABLE_ORDERS_PRODUCTS . " op on (o.orders_id = op.orders_id)" . "
                          where ot.class like '%ot_priority_handling%' and o.orders_status = s.orders_status_id and (o.orders_status = '1' or o.orders_status = '2') and (op.products_id = '9' or op.products_id = '16' or op.products_id = '10' or op.products_id = '13') and s.language_id = '" . (int)$_SESSION['languages_id'] . "'" .
                          $search . " order by o.orders_id DESC";
    }

When I run the above snippet, I get "WARNING: An Error occurred, please refresh the page and try again."

Any help would be greatly appreciated on figuring out where I went wrong.

P.S, As you go through the code, you will notice that I am only filtering for orders that are pending or in progress. I did not want to show completed or canceled orders.

16 Aug 2016, 4:20 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: WARNING: An Error occurred, please refresh the page and try again

You'll need to look at the error message that was recorded in your /logs/ folder, and then take action based on what it's telling you is wrong.
Ref: http://www.zen-cart.com/content.php?311-warning-an-error-occurred-please-refresh-the-page-and-try-again

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

16 Aug 2016, 5:09 PM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: WARNING: An Error occurred, please refresh the page and try again

Visually, I see two potential areas where something might go wrong though the directions DrByte offered are really the only help that can be provided considering the variables involved.

There are two "lines" where data is subsequently appended. If the follow-on data doesn't have a space in front, then the query could get "mangled". For example:

er_total" .
                          $new_fields

If $new_fields = 'new_field1' then the end of the previous line would append the new field onto the end like _totalnew_field1 and this is likely an unknown field. Having an extra space at the end won't hurt anything and would prevent a problem like I described... But, that myDebug file should reveal your issue(s).

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

16 Aug 2016, 6:31 PM
#4
riomaha avatar

riomaha

New Zenner

Join Date:
Oct 2013
Location:
MTL
Posts:
66
Plugin Contributions:
1

Re: WARNING: An Error occurred, please refresh the page and try again

Thank you both for guiding me. I checked the logs and indeed there an error just MC12345678 stated it would be. I didn't have the logs enabled at first and for that I apologize to everyone.

I was able to sort it out and that is in part thanks to you. I also realized, I was not adding the code to the right section of the page.
For those who are curious
I created a new drop down

 // prepare order-priority pulldown list
  $priority = array(array('id' => 'ot_priority_handling_categoryX', 'text' => Category X - Priority 1'), 
	array('id' => 'ot_priority_handling_2CategoryX', 'text' => 'Category X - Priority 4'), 
	array('id' => 'ot_priority_handling_3CategoryY', 'text' => 'Category Y Priority 1'), 
	array('id' => 'ot_priority_handling_4CategoryY', 'text' => 'Category Y Priority 4'));

Then below

            <div class="form-group col-xs-4 col-sm-3 col-md-3 col-lg-3">
              <?php echo zen_draw_form('status', FILENAME_ORDERS, '', 'get', '', true);
                echo '<label for="selectstatus" class="sr-only">' . HEADING_TITLE_STATUS . '</label> ' . zen_draw_pull_down_menu('status', array_merge(array(array('id' => '', 'text' => TEXT_ALL_ORDERS)), $orders_statuses), (int)$_GET['status'], 'class="form-control" onChange="this.form.submit();" id="selectstatus"');
                echo '</form>';
              ?>
            </div>

I added..

 <div class="form-group col-xs-4 col-sm-3 col-md-3 col-lg-3">
              <?php echo zen_draw_form('priority', FILENAME_ORDERS, '', 'get', '', true);
                echo '<label for="priority" class="sr-only">' . HEADING_TITLE_priority . '</label> ' . zen_draw_pull_down_menu('priority', array_merge(array(array('id' => '', 'text' => TEXT_ALL_ORDERS)), $priority), $_GET['priority'], 'class="form-control" onChange="this.form.submit();" id="priority"');
                echo '</form>';
              ?>
            </div>

Then above

// Only one or the other search
// create search_orders_products filter
  $search = '';
  $new_table = '';
  $new_fields = '';
  if (isset($_GET['search_orders_products']) && zen_not_null($_GET['search_orders_products'])) {

I added

// Only one or the other search
// create search_orders_products filter
  $search = '';
  $new_table = '';
  $new_fields = '';
if ($_GET['priority'] != '') {
if ($_GET['priority'] == 'ot_priority_categoryX') {
      $priority = zen_db_prepare_input($_GET['priority']);
      $orders_query_raw = "select o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.shipping_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, 'See Order Details' as order_total" . $new_fields ."
                          from (" . TABLE_ORDERS_STATUS . " s, " .
			  TABLE_ORDERS . " o " .
                          $new_table . ")
                          left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id)" . "
			  left join " . TABLE_ORDERS_PRODUCTS . " op on (o.orders_id = op.orders_id)" . "
                          where ot.class like '%ot_priority_handling%' and o.orders_status = s.orders_status_id and (o.orders_status = '1' or o.orders_status = '2') and (op.products_id = '9' or op.products_id = '16' or op.products_id = '10' or op.products_id = '13') and s.language_id = '" . (int)$_SESSION['languages_id'] . "'" .
                          $search . " order by o.orders_id DESC";
    } elseif ($_GET['priority'] == 'ot_priority_categoryY') {

      $priority = zen_db_prepare_input($_GET['priority']);
      $orders_query_raw = "select o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.shipping_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, 'See Order Details' as order_total" .
                          $new_fields . "
                          from (" . TABLE_ORDERS_STATUS . " s, " .
			  TABLE_ORDERS . " o " .
                          $new_table . ")
                          left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id)" . "
			  left join " . TABLE_ORDERS_PRODUCTS . " op on (o.orders_id = op.orders_id)" . "
                          where o.orders_status = s.orders_status_id and (o.orders_status = '1' or o.orders_status = '2') and (op.products_id = '9' or op.products_id = '16' or op.products_id = '10' or op.products_id = '13') and s.language_id = '" . (int)$_SESSION['languages_id'] . "'" .
                          $search . " order by o.orders_id DESC";

// Category Z
    } elseif ($_GET['priority'] == 'ot_priority_categoryZ') {
      $priority = zen_db_prepare_input($_GET['priority']);
      $orders_query_raw = "select o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.shipping_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, 'See Order Details' as order_total" .
                          $new_fields . "
                          from (" . TABLE_ORDERS_STATUS . " s, " .
			  TABLE_ORDERS . " o " .
                          $new_table . ")
                          left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id)" . "
			  left join " . TABLE_ORDERS_PRODUCTS . " op on (o.orders_id = op.orders_id)" . "
                          where ot.class like '%ot_priority_handling%' and o.orders_status = s.orders_status_id and (o.orders_status = '1' or o.orders_status = '2') and (op.products_id = '3' or op.products_id = '5' or op.products_id = '4' or op.products_id = '11') and s.language_id = '" . (int)$_SESSION['languages_id'] . "'" .
                          $search . " order by o.orders_id DESC";

    } elseif {......