Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,621
    Plugin Contributions
    123

    Default PHP Warning: Invalid UTF-8 sequence in argument in /ajax.php on line 24

    PHP Warning: Invalid UTF-8 sequence in argument in /ajax.php on line 24



    Prior to

    Code:
          echo json_encode ($result);exit();
    should there be something like

    Code:
          $result = htmlentities((string)$result, ENT_QUOTES, 'utf-8', FALSE);
    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.

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

    Default Re: PHP Warning: Invalid UTF-8 sequence in argument in /ajax.php on line 24

    Can you describe the steps you took to trigger the error message?
    .

    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.

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

    Default Re: PHP Warning: Invalid UTF-8 sequence in argument in /ajax.php on line 24

    Checkout by credit card (Paypal Express) with this item - the checkout confirmation page is blank in the center column, but the remainder of the page including the footer do render.

    The fix I suggested above seems to resolve this issue.
    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
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: PHP Warning: Invalid UTF-8 sequence in argument in /ajax.php on line 24

    Similar issue identified at: https://www.zen-cart.com/showthread....ment-with-V154

    The direction of this thread appeared to resolve the issue.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

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

    Default Re: PHP Warning: Invalid UTF-8 sequence in argument in /ajax.php on line 24

    FWIW, this change breaks one of my commercial plugins. That plugin returns an array of information to an AJAX request and the suggestion of simply casting the result to a string wrecks havoc!

    Here's the change that I made, allowing the return values to be string-value-containing-names or array elements:
    Code:
    <?php
    /**
     * ajax front controller
     *
     * @package core
     * @copyright Copyright 2003-2015 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version GIT: $Id: Author: Ian Wilson   Modified in v1.6.0 $
     */
    require ('includes/application_top.php');
    
    //-bof-lat9  *** 1 of 2 ***
    function htmlentities_mixed ($mixed_value, $flags, $encoding = 'utf-8', $double_encode = true) {
      if (!is_array ($mixed_value)) {
        $result = htmlentities ((string)$mixed_value, $flags, $encoding, $double_encode);
        
      } else {
        $result = array ();
        foreach ($mixed_value as $key => $value) {
          $result[$key] = htmlentities_mixed ($value, $flags, $encoding, $double_encode);
    
        }
      }
      return $result;
      
    }
    //-eof-lat9  *** 1 of 2 ***
    
    $language_page_directory = DIR_WS_LANGUAGES.$_SESSION['language'].'/';
    if (isset ($_GET['act'])&&isset ($_GET['method'])) {
      $className = 'zc'.ucfirst ($_GET['act']);
      $classFile = $className.'.php';
      if (file_exists (DIR_FS_CATALOG.DIR_WS_CLASSES.'ajax/'.$classFile)) {
        require (DIR_FS_CATALOG.DIR_WS_CLASSES.'ajax/'.$classFile);
        $class = new $className ();
        if (method_exists ($class, $_GET['method'])) {
          $result = call_user_func (array(
              $class,
              $_GET['method']
          ));
          
    //-bof-lat9  *** 2 of 2 ***
          $result = htmlentities_mixed ($result, ENT_QUOTES, 'utf-8', FALSE);
    //-eof-lat9  *** 2 of 2 ***
    
          echo json_encode ($result);exit();
        } else {
          echo 'method error';
        }
      }
    }

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

    Default Re: PHP Warning: Invalid UTF-8 sequence in argument in /ajax.php on line 24

    Quote Originally Posted by lat9 View Post
    FWIW, this change breaks one of my commercial plugins....
    What is the name of the plugin (so folks who are searching will come to this thread)?
    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.

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

    Default Re: PHP Warning: Invalid UTF-8 sequence in argument in /ajax.php on line 24

    That plugin's name is Products Options Stock Manager (POSM).

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

    Default Re: PHP Warning: Invalid UTF-8 sequence in argument in /ajax.php on line 24

    Proposed code change slated for v160: https://github.com/zencart/zencart/pull/613
    For v1.5.x the code by lat9 should be fine, and only involves touching 1 file.
    .

    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.

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

    Default Re: PHP Warning: Invalid UTF-8 sequence in argument in /ajax.php on line 24

    Thanks, DrByte!

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

    Default Re: PHP Warning: Invalid UTF-8 sequence in argument in /ajax.php on line 24

    I'm investigating reports of the previously-proposed "fix" being an incomplete, and potentially buggy, approach.

    To that end, I'm looking for any information any of you can provide to help me trigger the exact same symptoms with PayPal Pro on v154. Basically looking for details on how to set up a test site with settings to match yours in a way that I can trigger the symptoms ... so I can ensure we come up with as complete a fix as possible.

    Feedback welcome ;)
    .

    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.

 

 

Similar Threads

  1. Replies: 2
    Last Post: 20 May 2013, 04:09 AM
  2. Replies: 7
    Last Post: 4 Jan 2013, 09:21 PM
  3. PHP Warning: json_encode() Invalid UTF-8 sequence in argument
    By m.digregorio in forum General Questions
    Replies: 1
    Last Post: 15 Oct 2012, 08:30 PM
  4. Replies: 7
    Last Post: 23 Feb 2012, 01:15 PM
  5. Debug: USPS.php PHP Warning: Invalid argument supplied for foreach()
    By divinelighting in forum Addon Shipping Modules
    Replies: 2
    Last Post: 11 Jun 2011, 03:17 AM

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