Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2006
    Location
    Johannesburg
    Posts
    447
    Plugin Contributions
    1

    Default 157c Featured Product addition error when using South Africa dates.

    Using 157c (same issue found in 157b)

    When adding featured products in admin, if no date is selected, the product is added successfully. If however you enter the start and end dates the following error is generated.

    Newly upgraded to 157c, date format set as ddmmyyyy for use in South Africa. PHP 7.4 and MySQL 5.7

    Admin directory name changed for security reasons.


    08-Mar-2021 19:31:30 Africa/Johannesburg] Request URI: /xxxxxxadmin/index.php?cmd=featured&page=2&action=insert, IP address: 197.184.44.194
    #1 trigger_error() called at [/includes/classes/db/mysql/query_factory.php:170]
    #2 queryFactory->show_error() called at [/includes/classes/db/mysql/query_factory.php:142]
    #3 queryFactory->set_error() called at [/includes/classes/db/mysql/query_factory.php:269]
    #4 queryFactory->Execute() called at [/xxxxxxadmin/featured.php:39]
    #5 require(/xxxxxxxadmin/featured.php) called at [/xxxxxxxadmin/index.php:11]
    --> PHP Fatal error: 1292:Incorrect date value: '20213103' for column 'expires_date' at row 1 :: INSERT INTO astro_featured (products_id, featured_date_added, expires_date, status, featured_date_available)
    VALUES (3725,
    now(),
    '20213103',
    '1',
    '20210103') ==> (as called by) /xxxxxxadmin/featured.php on line 39 <== in /includes/classes/db/mysql/query_factory.php on line 170.

  2. #2
    Join Date
    Jul 2006
    Location
    Johannesburg
    Posts
    447
    Plugin Contributions
    1

    Default Re: 157c Featured Product addition error when using dates.

    I just noticed, it is also generating a fatal error in specials.

    --> PHP Fatal error: 1292:Incorrect date value: '20213103' for column 'expires_date' at row 1 :: UPDATE astro_specials
    SET specials_new_products_price = '30.4340',
    specials_last_modified = now(),
    expires_date = '20213103',
    specials_date_available = '20210103'
    WHERE specials_id = 227 ==> (as called by) /xxxxxadmin/specials.php on line 103 <== in /includes/classes/db/mysql/query_factory.php on line 170.

  3. #3
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,684
    Plugin Contributions
    123

    Default Re: 157c Featured Product addition error when using dates.

    You probably need to get some slashes in your date format, i.e. dd/mm/yyyy
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

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

    Default Re: 157c Featured Product addition error when using dates.

    Quote Originally Posted by Louis View Post
    Using 157c (same issue found in 157b)

    When adding featured products in admin, if no date is selected, the product is added successfully. If however you enter the start and end dates the following error is generated.

    Newly upgraded to 157c, date format set as ddmmyyyy for use in South Africa. PHP 7.4 and MySQL 5.7

    Admin directory name changed for security reasons.


    08-Mar-2021 19:31:30 Africa/Johannesburg] Request URI: /xxxxxxadmin/index.php?cmd=featured&page=2&action=insert, IP address: 197.184.44.194
    #1 trigger_error() called at [/includes/classes/db/mysql/query_factory.php:170]
    #2 queryFactory->show_error() called at [/includes/classes/db/mysql/query_factory.php:142]
    #3 queryFactory->set_error() called at [/includes/classes/db/mysql/query_factory.php:269]
    #4 queryFactory->Execute() called at [/xxxxxxadmin/featured.php:39]
    #5 require(/xxxxxxxadmin/featured.php) called at [/xxxxxxxadmin/index.php:11]
    --> PHP Fatal error: 1292:Incorrect date value: '20213103' for column 'expires_date' at row 1 :: INSERT INTO astro_featured (products_id, featured_date_added, expires_date, status, featured_date_available)
    VALUES (3725,
    now(),
    '20213103',
    '1',
    '20210103') ==> (as called by) /xxxxxxadmin/featured.php on line 39 <== in /includes/classes/db/mysql/query_factory.php on line 170.
    wow. who knew...

    in admin/featured.php, try adding the following code between lines 33 and 34:

    PHP Code:
    // first line below is 34
          
    $products_id = (int)$_POST['products_id'];
    //new code below:

            
    $featured_date_available_raw zen_db_prepare_input($_POST['featured_date_available']);
            if (
    DATE_FORMAT_DATE_PICKER != 'yy-mm-dd' && !empty($featured_date_available_raw)) {
              
    $local_fmt zen_datepicker_format_fordate();
              
    $dt DateTime::createFromFormat($local_fmt$featured_date_available_raw);
              
    $featured_date_available_raw 'null';
              if (!empty(
    $dt)) {
                
    $featured_date_available_raw $dt->format('Y-m-d');
              }
            }
            
    $featured_date_available = (date('Y-m-d') < $featured_date_available_raw) ? $featured_date_available_raw '0001-01-01';
            
    $expires_date_raw zen_db_prepare_input($_POST['expires_date']);
            if (
    DATE_FORMAT_DATE_PICKER != 'yy-mm-dd' && !empty($expires_date_raw)) {
              
    $local_fmt zen_datepicker_format_fordate();
              
    $dt DateTime::createFromFormat($local_fmt$expires_date_raw);
              
    $expires_date_raw 'null';
              if (!empty(
    $dt)) {
                
    $expires_date_raw $dt->format('Y-m-d');
              }
            }
            
    $expires_date = (date('Y-m-d') < $expires_date_raw) ? $expires_date_raw '0001-01-01';
    // end of new code. 
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

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

    Default Re: 157c Featured Product addition error when using dates.

    Quote Originally Posted by Louis View Post
    I just noticed, it is also generating a fatal error in specials.

    --> PHP Fatal error: 1292:Incorrect date value: '20213103' for column 'expires_date' at row 1 :: UPDATE astro_specials
    SET specials_new_products_price = '30.4340',
    specials_last_modified = now(),
    expires_date = '20213103',
    specials_date_available = '20210103'
    WHERE specials_id = 227 ==> (as called by) /xxxxxadmin/specials.php on line 103 <== in /includes/classes/db/mysql/query_factory.php on line 170.
    yeah. code duplication is a problem... i was looking at combining specials and featured together.... but time and other things get in the way...

    lmk if the code provided works....

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

  6. #6
    Join Date
    Jul 2006
    Location
    Johannesburg
    Posts
    447
    Plugin Contributions
    1

    Default Re: 157c Featured Product addition error when using dates.

    Sorry guys, never mind.

    The date format in admin/includes/English.php was not changed.

    I updated this to the following and the functions mentioned above are now working as they were intended.

    PHP Code:
    Return date in raw format

    // $date should be in format dd/mm/yyyy

    // raw date is in format YYYYMMDD, or DDMMYYYY

    function zen_date_raw($date$reverse false) {

      if (
    $reverse) {

        return 
    substr($date02) . substr($date32) . substr($date64);

      } else {

        return 
    substr($date64) . substr($date32) . substr($date02);

      }


    //

 

 

Similar Threads

  1. Shipping Module set up for South Africa
    By eastboy in forum General Questions
    Replies: 2
    Last Post: 29 Dec 2011, 01:28 PM
  2. South Africa Store Zone?
    By hmartens in forum Installing on a Linux/Unix Server
    Replies: 1
    Last Post: 19 Sep 2011, 12:58 AM
  3. Shipping Modules for South Africa
    By Parafanaylya in forum Addon Shipping Modules
    Replies: 10
    Last Post: 14 Apr 2008, 12:38 PM
  4. Payment by bank transfer - South Africa
    By windpower in forum Addon Payment Modules
    Replies: 0
    Last Post: 6 Apr 2008, 10:26 AM
  5. Payment Gateway for South Africa
    By dogmatic69 in forum General Questions
    Replies: 3
    Last Post: 26 Jan 2008, 07:24 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