Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22
  1. #11
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,668
    Plugin Contributions
    11

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

    Quote Originally Posted by DrByte View Post
    Thanks @carlwhat. We'll probably need to hard-code that into core.
    Quote Originally Posted by mc12345678 View Post
    In this way, templates don't need to do something "special" if the field is a datetime?
    i think when @drByte was talking about hard-code into core, he was referring to something similar to what you posted (i did not look that closely) as opposed to changes to any templates.

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

  2. #12
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

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

    Quote Originally Posted by carlwhat View Post
    i think when @drByte was talking about hard-code into core, he was referring to something similar to what you posted (i did not look that closely) as opposed to changes to any templates.

    best.
    I considered that; however, didn't see how the maximum value of 35 had been determined. I of course also didn't look into each of the "time"ish types to see what the various maximums are/were and focused on datetime as it is the combination of both date and time and applied here. :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #13
    Join Date
    Jan 2015
    Location
    Cyprus
    Posts
    41
    Plugin Contributions
    0

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

    Hi Guys,
    Finally what is the recommended or final solution for the specific problem
    Every time someone logs on the store the following error appears. ZC 1.5.7.c, Mysql 5.7.31, PHP 7.4.23
    [27-Sep-2021 03:26:14 UTC] Request URI: /index.php?main_page=login, IP address: 114.119.129.92
    #1 zen_set_field_length() called at [/includes/templates/bootstrap/templates/tpl_modules_create_account.php:174]
    #2 require(/includes/templates/bootstrap/templates/tpl_modules_create_account.php) called at [/includes/templates/bootstrap/templates/tpl_login_default.php:138]
    #3 require(/includes/templates/bootstrap/templates/tpl_login_default.php) called at [/includes/templates/bootstrap/common/tpl_main_page.php:197]
    #4 require(/includes/templates/bootstrap/common/tpl_main_page.php) called at [/index.php:94]
    --> PHP Warning: A non-numeric value encountered in /includes/functions/functions_general.php on line 746.

  4. #14
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,668
    Plugin Contributions
    11

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

    stop asking customers for their date of birth.

    that’s a simple config switch in the admin to turn off.

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

  5. #15
    Join Date
    Jan 2015
    Location
    Cyprus
    Posts
    41
    Plugin Contributions
    0

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

    By turning off the date of birth all errors including the non-numeric value and the crashing of the database went away!!! I hope this is fixed soon as the DOB is a marketing tool.
    Thanks a lot,
    George

  6. #16
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,668
    Plugin Contributions
    11

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

    Quote Originally Posted by Georgecy View Post
    By turning off the date of birth all errors including the non-numeric value and the crashing of the database went away!!! I hope this is fixed soon as the DOB is a marketing tool.
    Thanks a lot,
    George
    if you want DOB, refer to post #9 above and do as instructed.

    https://www.zen-cart.com/showthread....61#post1378361
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  7. #17
    Join Date
    Jan 2015
    Location
    Cyprus
    Posts
    41
    Plugin Contributions
    0

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

    Quote Originally Posted by carlwhat View Post
    if you want DOB, refer to post #9 above and do as instructed.

    https://www.zen-cart.com/showthread....61#post1378361
    That was the first thing I did, more than one time and did not worked. I did the change first in the default/Templates/ as are the instructions and last I did the change in the Boostrap/Templates/ and it not work either. I think @drByte and @lat9 should look into this issue again as turning the DOB off is not a solution.

  8. #18
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

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

    Quote Originally Posted by Georgecy View Post
    That was the first thing I did, more than one time and did not worked. I did the change first in the default/Templates/ as are the instructions and last I did the change in the Boostrap/Templates/ and it not work either. I think @drByte and @lat9 should look into this issue again as turning the DOB off is not a solution.
    Addressing the issue at its root-cause requires change to /includes/classes/db/mysql/query_factory.php. This is the class that creates the $db object, so be sure to make a backup and place the site into maintenance-mode prior to any change.

    At the end of the file, find:
    Code:
    class queryFactoryMeta {
    
      function __construct($zp_field) {
        $type = $zp_field['Type'];
        $rgx = preg_match('/^[a-z]*/', $type, $matches);
        $this->type = $matches[0];
        $this->max_length = preg_replace('/[a-z\(\)]/', '', $type);
      }
    }
    and replace that section with:
    Code:
    class queryFactoryMeta 
    {
        public function __construct($zp_field)
        {
            $type = $zp_field['Type'];
            switch ($type) {
                case 'date':
                    $this->max_length = 10; //- YYYY-MM-DD
                    break;
                case 'datetime':
                    $this->max_length = 19; //- YYYY-MM-DD HH:MM:SS
                    break;
                default:
                    $rgx = preg_match('/^[a-z]*/', $type, $matches);
                    $this->type = $matches[0];
                    $this->max_length = preg_replace('/[a-z\(\)]/', '', $type);
                    break;
            }
        }
    }
    That change recognizes that date and datetime type database fields don't include a maximum length in-and-of themselves.
    Last edited by swguy; 4 Nov 2021 at 06:16 PM. Reason: correcting file path

  9. #19
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

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

    FWIW, I've opened a GitHub issue to track the changes: https://github.com/zencart/zencart/issues/4467

  10. #20
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

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

    Looking to make that GitHub update, I see that @DrByte has already addressed that change:
    Code:
    class queryFactoryMeta {
    
      function __construct($zp_field) {
        $type = $zp_field['Type'];
        $rgx = preg_match('/^[a-z]*/', $type, $matches);
        $this->type = $matches[0];
        $this->max_length = preg_replace('/[a-z\(\)]/', '', $type);
        if (empty($this->max_length)) {
            if (strtoupper($type) === 'DATE') $this->max_length = 10;
            if (strtoupper($type) === 'DATETIME') $this->max_length = 19; // ignores fractional which would be 26
            if (strtoupper($type) === 'TIMESTAMP') $this->max_length = 19; // ignores fractional which would be 26
         }
      }
    }

 

 
Page 2 of 3 FirstFirst 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