Page 1 of 3 123 LastLast
Results 1 to 10 of 22
  1. #1
    Join Date
    Mar 2008
    Location
    Belgium
    Posts
    115
    Plugin Contributions
    6

    help question A non-numeric value encountered in functions_general.php

    ZC: v1.5.7b
    PHP: 7.4.15
    Mods:
    • edit_orders-4.5.5
    • catalog_invoice
    • ip_blocker-2.2.0
    • sales_report-3.4.0
    • quantity_discounts


    In logs this appeared when I logged in with my test-account:
    Code:
    [23-Feb-2021 12:58:07 Europe] Request URI: /index.php?main_page=login, IP address: *.*.*.*
    #1  zen_set_field_length()
     called at [/data/sites/web/your_site/www/includes/templates/template_default/templates/tpl_modules_create_account.php:142]
    #2  require(/data/sites/web/your_site/www/includes/templates/template_default/templates/tpl_modules_create_account.php)
     called at [/data/sites/web/your_site/www/includes/templates/template_default/templates/tpl_login_default.php:90]
    #3  require(/data/sites/web/your_site/www/includes/templates/template_default/templates/tpl_login_default.php)
     called at [/data/sites/web/your_site/www/includes/templates/responsive_classic/common/tpl_main_page.php:178]
    #4  require(/data/sites/web/your_site/www/includes/templates/responsive_classic/common/tpl_main_page.php)
     called at [/data/sites/web/your_site/www/index.php:94]
    --> PHP Warning: A non-numeric value encountered in
     /data/sites/web/your_site/www/includes/functions/functions_general.php on line 746.
    I took the advice from DrByte from post #2 in A non-numeric value encountered in shopping_cart.php and adjusted it to the line.

    Location of the adjustment in includes/functions/functions_general.php.

    PHP Code:
                $length 'size="' . ($field_length 1) . '" maxlength="' $field_length '"'//Line 746
                // To find out what goes wrong
    if (!is_numeric($length)) { var_dump($length); die(); } //Only this line added
                
    break;
        }
        return 
    $length
    When I try to log in as a customer, on the login page in the new account field:
    First Name:string(24) "size="33" maxlength="32""

    I couldn't a solution. Than I change the varchar in the database from 32 to 34 for the column "customer_firstname"
    Result: both number went up: size and maxlength.

    Is ip_blocker-2.2.0 maybe to blame? That's the last add-on.

  2. #2
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,682
    Plugin Contributions
    9

    Default Re: A non-numeric value encountered in functions_general.php

    Quote Originally Posted by Philibel View Post
    In logs this appeared when I logged in with my test-account:
    [CODE][23-Feb-2021 12:58:07 Europe] Request URI: /index.php?main_page=login, IP address: *.*.*.*
    #1 zen_set_field_length()
    called at [/data/sites/web/your_site/www/includes/templates/template_default/templates/tpl_modules_create_account.php:142]
    the problem looks to be with date of birth. line 142:

    https://github.com/zencart/zencart/b...count.php#L142

    do you require date of birth for customers? does it exist in your customers table?

    best.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  3. #3
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: A non-numeric value encountered in functions_general.php

    Does editing line 740 of functions_general like this help?

    Code:
    $field_length = (int)zen_field_length($tbl, $fld);
    .

    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.

  4. #4
    Join Date
    Mar 2008
    Location
    Belgium
    Posts
    115
    Plugin Contributions
    6

    Default Re: A non-numeric value encountered in functions_general.php

    @carlwhat
    line 142: same as the Github-version
    PHP Code:

    <?php echo zen_draw_input_field('dob',''zen_set_field_length(TABLE_CUSTOMERS'customers_dob''20') . ' id="dob" placeholder="' ENTRY_DATE_OF_BIRTH_TEXT '"' . (ACCOUNT_DOB == 'true' && (int)ENTRY_DOB_MIN_LENGTH != ' required' '')); ?>

    date of birth: is set "true"
    It exists in the customers table:
    PHP Code:

      
    `customers_dobdatetime NOT NULL DEFAULT '0001-01-01 00:00:00'
    I'm going to try DrByte's suggestion next and get back on that.

  5. #5
    Join Date
    Mar 2008
    Location
    Belgium
    Posts
    115
    Plugin Contributions
    6

    Default Re: A non-numeric value encountered in functions_general.php

    Code:
    $field_length = (int)zen_field_length($tbl, $fld);
    It doesn't give a warning log anymore, so that good.
    Until I tried to register as a customer: the date of birth field accepts nothing. You can select it but numbers nor text appears.

    After I removed (int), typing was enabled again.

  6. #6
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,682
    Plugin Contributions
    9

    Default Re: A non-numeric value encountered in functions_general.php

    Quote Originally Posted by Philibel View Post
    Code:
    $field_length = (int)zen_field_length($tbl, $fld);
    It doesn't give a warning log anymore, so that good.
    Until I tried to register as a customer: the date of birth field accepts nothing. You can select it but numbers nor text appears.

    After I removed (int), typing was enabled again.
    definite bug in the code. see:

    Name:  Screenshot from 2021-02-24 14-21-50.png
Views: 232
Size:  10.2 KB

    max_length for datetime length is an empty string. casting it to an integer gives you 0.

    you have a few options. 2 off the top of my head are:
    • turn the requirement for DOB off.
    • hand code the html that gets generated in this section as below.


    PHP Code:
    zen_draw_input_field('dob','''size="20" maxlength="35" id="dob" placeholder="' ENTRY_DATE_OF_BIRTH_TEXT '"' . (ACCOUNT_DOB == 'true' && (int)ENTRY_DOB_MIN_LENGTH != ' required' '')); 
    feel free to change the size and maxlength to numbers of your liking.

    hope that helps.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  7. #7
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: A non-numeric value encountered in functions_general.php

    Thanks @carlwhat. We'll probably need to hard-code that into core.

    @Philibel what MySQL version are you using?
    .

    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
    Mar 2008
    Location
    Belgium
    Posts
    115
    Plugin Contributions
    6

    Default Re: A non-numeric value encountered in functions_general.php

    @carlwhat:

    I've an appointment so I'll take a look later on.

    @DrByte:

    Database Engine: MySQL 5.7.31-34-log

  9. #9
    Join Date
    Mar 2008
    Location
    Belgium
    Posts
    115
    Plugin Contributions
    6

    Default Re: A non-numeric value encountered in functions_general.php

    @carlwhat:

    I replaced line 142 in /includes/templates/template_default/templates/tpl_modules_create_account.php with:

    PHP Code:

    <?php echo zen_draw_input_field('dob','''size="20" maxlength="35" id="dob" placeholder="' ENTRY_DATE_OF_BIRTH_TEXT '"' . (ACCOUNT_DOB == 'true' && (int)ENTRY_DOB_MIN_LENGTH != ' required' '')); ?>
    * Typing in the field works
    * No error log is created
    * looks ok now

    Thank you both for helping me out on this.

  10. #10
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: A non-numeric value encountered in functions_general.php

    Quote Originally Posted by carlwhat View Post
    definite bug in the code. see:

    Name:  Screenshot from 2021-02-24 14-21-50.png
Views: 232
Size:  10.2 KB

    max_length for datetime length is an empty string. casting it to an integer gives you 0.

    you have a few options. 2 off the top of my head are:
    • turn the requirement for DOB off.
    • hand code the html that gets generated in this section as below.


    PHP Code:
    zen_draw_input_field('dob','''size="20" maxlength="35" id="dob" placeholder="' ENTRY_DATE_OF_BIRTH_TEXT '"' . (ACCOUNT_DOB == 'true' && (int)ENTRY_DOB_MIN_LENGTH != ' required' '')); 
    feel free to change the size and maxlength to numbers of your liking.

    hope that helps.
    Quote Originally Posted by DrByte View Post
    Thanks @carlwhat. We'll probably need to hard-code that into core.

    @Philibel what MySQL version are you using?
    Isn't the maximum length of a datetime field 26 characters based on:
    Code:
    the range for DATETIME values is '1000-01-01 00:00:00.000000' to '9999-12-31 23:59:59.999999'
    As provided at: https://dev.mysql.com/doc/refman/8.0/en/datetime.html or the 5.7 equivalent?

    Where this could be "addressed" in https://github.com/zencart/zencart/b...ry_factory.php at/around line 717 with something like:

    Code:
        $this->max_length = preg_replace('/[a-z\(\)]/', '', $type);
        if ($type == 'datetime') {
          $this->max_length = '26';
        }
    In this way, templates don't need to do something "special" if the field is a datetime? Possibly another/additional method could be used such as determining if the word 'time' is in the $type and use some "predefined" size as the other "time" type fields are somewhat similar?

    FYI, I chose a string version of the number instead of just assigning it to a number to maintain the datatype the same throughout.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. v157 A non-numeric value encountered in shopping_cart.php
    By simon1066 in forum General Questions
    Replies: 15
    Last Post: 9 Jan 2021, 03:57 PM
  2. v155 Php Warning A non-numeric value encountered
    By ianhg in forum General Questions
    Replies: 1
    Last Post: 3 Jul 2019, 10:56 AM
  3. Replies: 1
    Last Post: 15 Dec 2018, 10:54 PM
  4. Replies: 2
    Last Post: 18 Nov 2018, 04:06 AM
  5. Replies: 38
    Last Post: 1 Nov 2018, 09:28 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