Page 4 of 5 FirstFirst ... 2345 LastLast
Results 31 to 40 of 42
  1. #31
    Join Date
    Dec 2011
    Posts
    2
    Plugin Contributions
    0

    Default Re: PHP Warning: strlen() expects parameter 1 to be string

    Quote Originally Posted by DrByte View Post
    Therein is the problem. It is almost NEVER getting an array. The ONLY time it gets an array is when the product-notifications screen is presented. The zillion other times that the function is used there is no array passed at all.
    I submit that your proposed fix is likely to cause the entire function to not return the right results, thus preventing normal operation of the majority of cases where this function is called.
    Thus, its NOT SAFE to be used on live sites, unless of course you want to encounter lost sales and poor customer experience while shopping.
    Fair point, then you just add a test for an array before it

    A quick example is below

    PHP Code:

    $valueStr
    =0
     
    if (isarray($value)) { 
         
    $valueStr=count($value)
    }else {
         
    $valueStr=strlen($value)
    }

    if ( (!
    in_array($key$exclude_array)) && $valueStr 0) && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && ($key != 'x') && ($key != 'y') ) { 
              if ( (
    SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) { 

  2. #32
    Join Date
    Nov 2011
    Posts
    1
    Plugin Contributions
    0

    Default Re: PHP Warning: strlen() expects parameter 1 to be string

    Quote Originally Posted by torvista View Post
    Thanks for the interest.

    This is exactly what I have in the live shop code:

    PHP Code:
           while (list($key$value) = each($_GET)) {
          if (
    is_array($value)) trigger_error('GET param found to be array: ' print_r($valuetrue) . '  --- contents of GET: ' print_r($_GETtrue));//steve looking for reason, as per http://www.zen-cart.com/forum/showthread.php?t=176804
            //if ( (strlen($value) > 0) && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array)) && ($key != 'x') && ($key != 'y') ) {//steve original line 
        
    if ( (!in_array($key$exclude_array)) && (strlen($value) > 0) && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && ($key != 'x') && ($key != 'y') ) {//steve this line edited to stop debug error as per http://www.zen-cart.com/forum/showthread.php?p=1070316#post1070316
              
    if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) { 
    You just forgot to remove the line containing trigger_error call.

  3. #33
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    1,262
    Plugin Contributions
    24

    Default Re: PHP Warning: strlen() expects parameter 1 to be string

    You just forgot to remove the line containing trigger_error call.
    You mean the debug was caused by the info, not the original fault!
    Doh!
    Steve
    "Totally Zenned" my a*se!

  4. #34
    Join Date
    Jan 2004
    Posts
    60,419
    Blog Entries
    4
    Plugin Contributions
    144

    Default Re: PHP Warning: strlen() expects parameter 1 to be string

    What were the actual messages in the most recently logs? If they weren't text generated by the trigger_error() call you had in your code, then that's not the issue.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donations always welcome: www.zen-cart.com/donate

    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.



  5. #35
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    1,262
    Plugin Contributions
    24

    Default Re: PHP Warning: strlen() expects parameter 1 to be string

    Since the solution posted in post 16, the debug "errors" have indeed just been the output of the error trigger, I just didn't think about it long enough to realise!

    15-Dec-2011 15:45:48] PHP Notice: GET param found to be array: Array
    (
    [0] => 136
    )
    --- contents of GET: Array
    (
    [main_page] => index
    [action] => notify
    [notify] => Array
    (
    [0] => 136
    )

    )
    in blah blah.
    Steve
    "Totally Zenned" my a*se!

  6. #36
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    1,262
    Plugin Contributions
    24

    Default now in 1.5

    after a week running my upgrade to 1.5 I get this error again for the first time:
    [31-Jan-2012 20:39:06] PHP Warning: strlen() expects parameter 1 to be string, array given in /home/XXXX/public_html/tienda/includes/functions/functions_general.php on line 152

    FYI, from functions_general.php
    PHP Code:
     function zen_get_all_get_params($exclude_array ''$search_engine_safe true) {

        if (!
    is_array($exclude_array)) $exclude_array = array();

        
    $get_url '';
        if (
    is_array($_GET) && (sizeof($_GET) > 0)) {
          
    reset($_GET);
          while (list(
    $key$value) = each($_GET)) {
            if ( (!
    in_array($key$exclude_array)) && (strlen($value) > 0) && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && ($key != 'x') && ($key != 'y') ) {
              if ( (
    SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {
    //    die ('here');
                
    $get_url .= $key '/' rawurlencode(stripslashes($value)) . '/';
              } else {
                
    $get_url .= zen_sanitize_string($key) . '=' rawurlencode(stripslashes($value)) . '&';
              }
            }
          }
        }
        while (
    strstr($get_url'&&')) $get_url str_replace('&&''&'$get_url);
        while (
    strstr($get_url'&&')) $get_url str_replace('&&''&'$get_url);

        return 
    $get_url;
      } 
    Although the cause of the error has already been detailed previously I can confirm its the same:
    create a new customer
    make a purchase
    and after checkout, when presented with the screen and the option to receive product updates (which is already ticked), click on update rather than logout.
    Steve
    "Totally Zenned" my a*se!

  7. #37
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    1,262
    Plugin Contributions
    24

    Default Re: PHP Warning: strlen() expects parameter 1 to be string

    I understand this error "doesn't matter" but as the fix included in 1.5 does not work (at least on my site), how can I stop this debug error being created (on most sales)?

    Its the only fault I get and it's an unnecessary maintenance task to have to check and delete them continually.
    Steve
    "Totally Zenned" my a*se!

  8. #38
    Join Date
    Jan 2004
    Posts
    60,419
    Blog Entries
    4
    Plugin Contributions
    144

    Default Re: PHP Warning: strlen() expects parameter 1 to be string

    Quick and dirty idea: if you and your customers don't actually use the product-notification feature, turn it off and/or delete that form from the checkout-success template, and then none of those inputs will trigger the problems you're complaining about.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donations always welcome: www.zen-cart.com/donate

    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. #39
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    1,262
    Plugin Contributions
    24

    Default Re: PHP Warning: strlen() expects parameter 1 to be string

    Thanks. I appreciate this is a less than minor problem...and I'll avoid it as you suggest.
    Nonetheless I am curious to know why the fix doesn't work (is it just my site?) or does it require a more complicated fix?
    I am used to Zen Cart having no errors at all so this stands out.
    regards
    Steve
    Steve
    "Totally Zenned" my a*se!

  10. #40
    Join Date
    Jan 2004
    Posts
    60,419
    Blog Entries
    4
    Plugin Contributions
    144

    Default Re: PHP Warning: strlen() expects parameter 1 to be string

    Try this replacement code as the fix:
    Code:
      function zen_get_all_get_params($exclude_array = '', $search_engine_safe = true) {
    
        if (!is_array($exclude_array)) $exclude_array = array();
        $exclude_array = array_merge($exclude_array, array(zen_session_name(), 'main_page', 'error', 'x', 'y'));
        $get_url = '';
        if (is_array($_GET) && (sizeof($_GET) > 0)) {
          reset($_GET);
          while (list($key, $value) = each($_GET)) {
            if (is_array($value) || in_array($key, $exclude_array)) continue;
            if (strlen($value) > 0) {
              $get_url .= zen_sanitize_string($key) . '=' . rawurlencode(stripslashes($value)) . '&';
            }
          }
        }
        while (strstr($get_url, '&&')) $get_url = str_replace('&&', '&', $get_url);
        while (strstr($get_url, '&&')) $get_url = str_replace('&&', '&', $get_url);
    
        return $get_url;
      }
    Suitable for v1.3.9a thru v1.5.0
    Fix included in v1.5.1
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donations always welcome: www.zen-cart.com/donate

    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.



 

 
Page 4 of 5 FirstFirst ... 2345 LastLast

Similar Threads

  1. PHP Warning: addslashes() expects parameter 1 to be string, array given
    By schoolboy in forum All Other Contributions/Addons
    Replies: 11
    Last Post: 10 May 2013, 02:19 PM
  2. v139h PHP Warning: strip_tags() expects parameter 1 to be string, array given
    By BlessIsaacola in forum General Questions
    Replies: 1
    Last Post: 6 Mar 2012, 01:32 PM
  3. v150 PHP Warning: strlen() expects parameter 1 to be string, array given
    By caffeitalia in forum General Questions
    Replies: 1
    Last Post: 1 Feb 2012, 03:17 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
  •