Page 1 of 4 123 ... LastLast
Results 1 to 10 of 39
  1. #1
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    1,991
    Plugin Contributions
    29

    Default [Done v1.5.6] PHP Warning: A non-numeric value encountered... - PHP 7 warnings

    I have had a couple of these debug warnings with PHP 7.1. No doubt there will be more...

    1) in advanced_search_result_header.php

    I changed

    $rate = $currencies->get_value($_SESSION['currency']);
    if ($rate) {
    $pfrom = $_GET['pfrom'] / $rate;
    $pto = $_GET['pto'] / $rate;}
    to
    $rate = $currencies->get_value($_SESSION['currency']);
    if ($rate) {
    $pfrom = (float)$_GET['pfrom'] / $rate;//steve added float for PHP 7 warning
    $pto = (float)$_GET['pto'] / $rate;//steve added float for PHP 7 warning
    }
    Note this was provoked by an url like this
    SHOP_ROOT/index.php?main_page=advanced_search_result&keyword=asas&search_in_description=1& categories_id=&inc_subcat=1&manufacturers_id=&pfrom=&pto=&dfrom=&dto=

    2) functions_taxes.php

    I changed
    // Calculates Tax rounding the result function
    zen_calculate_tax($price, $tax = 0) {
    $price = $price;
    $tax = $tax;
    //eof global $currencies;
    return $price * $tax / 100;
    }
    to
    // Calculates Tax rounding the result
    function zen_calculate_tax($price, $tax = 0) {
    $price = (float)$price; //steve added float for PHP 7 warning
    $tax = (float)$tax; //steve added float for PHP 7 warning
    //eof global $currencies;
    return $price * $tax / 100;
    }
    Last edited by torvista; 1 Aug 2017 at 11:01 AM.
    Steve
    github.com/torvista: Apsona (php7), BackupMySQL Admin/Auto, Product Listing Sorter, Redsys payment module, Spanish Language Pack and more...

  2. #2
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    1,400
    Plugin Contributions
    2

    Default Re: PHP Warning: A non-numeric value encountered... - PHP 7 warnings

    confirmed the problem and solution for advanced_search.

  3. #3
    Join Date
    Feb 2009
    Location
    UK
    Posts
    619
    Plugin Contributions
    0

    Default PHP Warning: A non-numeric value encountered... categories_ul_generator.php

    V1.5.5e
    PHP v7.1.1
    Stirling Grand Template
    css_js_loader
    Dynamic Price Updater
    One page checkout
    SBA
    User tracking
    Zen Magnific
    CEON
    Elastislide & Responsive Image Gallery
    Dynamic Attr. Filter

    This might be the place for these errors so,

    I have a similar debug error

    PHP Warning: A non-numeric value encountered in C:\mylocalserver\www\mydomain.co.uk\includes\classes\categories_ul_generator.php on line 58

    said line is:
    PHP Code:
     $result sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level+1) . '"' '' ); 
    error remedied, with no obvious effect, by changing to:

    PHP Code:
    $result sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level) . '"' '' ); 
    it would be good to know the actual effect that had. The line comes from this block:
    PHP Code:
    function buildBranch($parent_id$level 0$submenu=true$parent_link='')
        {
            
    $result sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level+1) . '"' '' );
            
            if ((
    $this->data[$parent_id])) {
                foreach(
    $this->data[$parent_id] as $category_id => $category) {
                    
    $category_link $parent_link $category_id;
                    if ((
    $this->data[$category_id])) {
                        
    $result .= sprintf($this->child_start_string, ($submenu==true) ? ' class="submenu"' '');
                    } else {
                        
    $result .= sprintf($this->child_start_string'');
                    }
                    
    $result .= str_repeat($this->spacer_string$this->spacer_multiplier 1) . '<a href="' zen_href_link(FILENAME_DEFAULT'cPath=' $category_link) . '">';
                    
    $result .= $category['name'];
                    
    $result .= '</a>';
                      
                    if ((
    $this->data[$category_id]) && (($this->max_level == '0') || ($this->max_level $level+1))) {
                        
    $result .= $this->buildBranch($category_id$level+1$submenu$category_link '_');
                    }
                    
    $result .= $this->child_end_string;
                }
            }
            
            
    $result .= $this->parent_group_end_string;
            return 
    $result;
        } 
    I have the original line 58 in
    ZC v1.5.4/PHP v5.6.5
    ZC v1.5.5a/PHP v5.6.5
    both of which worked fine, I suspect it might be a PHP 7 issue.

    What do you think?

  4. #4
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    1,400
    Plugin Contributions
    2

    Default Re: PHP Warning: A non-numeric value encountered... categories_ul_generator.php

    don't like it. changes what the function is doing. i would change the line to:

    PHP Code:
    $result sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ((float)$level+1) . '"' '' ); 
    note that this is a warning, and php 7 now issues warnings when attempting arithmetic operations on strings or null values. while it is a change i would hardly call it an issue with php7.

    best.
    no good deed goes unpunished. help out with the green....

  5. #5
    Join Date
    Feb 2009
    Location
    UK
    Posts
    619
    Plugin Contributions
    0

    Default Re: PHP Warning: A non-numeric value encountered... categories_ul_generator.php

    That's great, thank you for clarifying that.

    Edit: fixed that, more of the same at:

    ..\includes\functions\functions_taxes.php on line 172.

    torvista was right.
    Last edited by simon1066; 20 Aug 2017 at 06:44 PM.

  6. #6
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    1,400
    Plugin Contributions
    2

    Default Re: PHP Warning: A non-numeric value encountered... - PHP 7 warnings

    be careful w taxes fix. i think this is the recommended fix:

    https://github.com/zencart/zencart/pull/1437/files

  7. #7
    Join Date
    Jan 2004
    Posts
    65,255
    Blog Entries
    7
    Plugin Contributions
    226

    Default Re: PHP Warning: A non-numeric value encountered... categories_ul_generator.php

    Quote Originally Posted by simon1066 View Post
    That's great, thank you for clarifying that.

    Edit: fixed that, more of the same at:

    ..\includes\functions\functions_taxes.php on line 172.

    torvista was right.
    The CORRECT way to fix this one is shown here: #18 ... everything else is a bandage.
    .

    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.

  8. #8
    Join Date
    Feb 2009
    Location
    UK
    Posts
    619
    Plugin Contributions
    0

    Default Re: PHP Warning: A non-numeric value encountered... categories_ul_generator.php

    Thank you, I had forgotten to look at the bug fixes thread.

  9. #9
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,443
    Plugin Contributions
    9

    Default Re: PHP Warning: A non-numeric value encountered... categories_ul_generator.php

    Had a similar error on a client's site (ZC 1.5.5e) asf:

    [19-Oct-2017 16:33:21 UTC] PHP Warning: A non-numeric value encountered in includes/modules/pages/advanced_search_result/header_php.php on line 368
    The recommended fix

    https://github.com/zencart/zencart/pull/1437/files

    made no difference at all.

    So, I applied torvista's suggestion which appears to work. Not saying it is the *correct* fix but the cart now runs without errors.

  10. #10
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    1,400
    Plugin Contributions
    2

    Default Re: PHP Warning: A non-numeric value encountered... categories_ul_generator.php

    Quote Originally Posted by frank18 View Post
    Had a similar error on a client's site (ZC 1.5.5e) asf:

    The recommended fix

    https://github.com/zencart/zencart/pull/1437/files

    made no difference at all.

    So, I applied torvista's suggestion which appears to work. Not saying it is the *correct* fix but the cart now runs without errors.
    the recommended fix deals with tax problems, not with advanced_search_results....

    your error log clearly states an issues with advanced search results, which is a different fix than the tax one. so i would recommend applying them both.

    i find @torvista s work solid and agree with most things he brings up; certainly in this case, it does address your issue....

    best.
    no good deed goes unpunished. help out with the green....

 

 
Page 1 of 4 123 ... LastLast

Similar Threads

  1. Replies: 1
    Last Post: 15 Dec 2018, 10:54 PM
  2. Replies: 2
    Last Post: 18 Nov 2018, 04:06 AM
  3. Replies: 0
    Last Post: 18 Feb 2018, 06:26 PM
  4. Replies: 20
    Last Post: 7 Dec 2014, 11:29 AM
  5. Replies: 0
    Last Post: 27 Sep 2012, 11:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR