Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 2012
    Posts
    209
    Plugin Contributions
    1

    Idea or Suggestion PHP Warning: trim() expects parameter 1 to be string, array given in ....

    Getting this , how to fix


    PHP Warning: trim() expects parameter 1 to be string, array given in ../includes/functions/functions_general.php on line 63

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

    Default Re: PHP Warning: trim() expects parameter 1 to be string, array given in ....

    Considering how little information is provided to reproduce the issue, the only answer I can undoubtedly and without question provide is to ensure that parameter 1 is a string...

    A more pointed answer might be possible if knew things like what version of Zen Cart is actually installed, what version of PHP is active, what changes have been incorporated into the site, what the call history is/was when this issue arose, etc...
    Last edited by mc12345678; 27 Dec 2018 at 06:46 AM. Reason: Was hard to find, but v155 was asked about
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Apr 2012
    Posts
    209
    Plugin Contributions
    1

    Default Re: PHP Warning: trim() expects parameter 1 to be string, array given in ....

    PHP 7.0


    PHP Warning: trim() expects parameter 1 to be string, array given in /includes/functions/functions_general.php on line 63
    [27-Dec-2018 09:55:03 Asia/Kolkata] Request URI: /?selid[201]=1379, IP address: 182.56.82.231
    #1 trim() called at [/includes/functions/functions_general.php:63]
    #2 zen_parse_input_field_data() called at [/includes/functions/functions_general.php:77]
    #3 zen_output_string() called at [/includes/functions/html_output.php:699]
    #4 zen_draw_hidden_field() called at [/includes/modules/header_currencies.php:33]
    #5 require(/includes/modules/header_currencies.php) called at [/includes/templates/sstailor/common/tpl_header.php:276]
    #6 require(/includes/templates/sstailor/common/tpl_header.php) called at [/includes/templates/sstailor/common/tpl_main_page.php:183]
    #7 require(/includes/templates/sstailor/common/tpl_main_page.php) called at [/index.php:97]

  4. #4
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: PHP Warning: trim() expects parameter 1 to be string, array given in ....

    Looks like the issue might be in:
    Code:
    /includes/templates/sstailor/common/tpl_header.php
    at or before line: 276. Either that or the header_currencies file has been modified, but by it being in the normal "core" area, it doesn't seem that there are any changes. :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Apr 2012
    Posts
    209
    Plugin Contributions
    1

    Default Re: PHP Warning: trim() expects parameter 1 to be string, array given in ....

    the header_currency file is as follows


    // test if box should display
    $show_currencies= false;

    // don't display on checkout page:
    if (substr($current_page, 0, 8) != 'checkout') {
    $show_currencies= true;
    }

    if ($show_currencies == true) {
    if (isset($currencies) && is_object($currencies)) {

    reset($currencies->currencies);
    $currencies_array = array();
    while (list($key, $value) = each($currencies->currencies)) {
    $currencies_array[] = array('id' => $key, 'text' => (zen_not_null($value['symbol_left']) ? $value['symbol_left'] : $value['symbol_right']) );

    }

    $hidden_get_variables = '';
    reset($_GET);
    while (list($key, $value) = each($_GET)) {
    if ( ($key != 'currency') && ($key != zen_session_name()) && ($key != 'x') && ($key != 'y') ) {
    $hidden_get_variables .= zen_draw_hidden_field($key, $value);
    }
    }


    require($template->get_template_dir('tpl_header_currencies.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header_currencies.php');
    }
    }

  6. #6
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: PHP Warning: trim() expects parameter 1 to be string, array given in ....

    Quote Originally Posted by diptimoy View Post
    the header_currency file is as follows

    Code:
    <?php
    // test if box should display
      $show_currencies= false;
    
      // don't display on checkout page:
      if (substr($current_page, 0, 8) != 'checkout') {
        $show_currencies= true;
      }
    
      if ($show_currencies == true) {
        if (isset($currencies) && is_object($currencies)) {
    
          reset($currencies->currencies);
          $currencies_array = array();
          while (list($key, $value) = each($currencies->currencies)) {
           $currencies_array[] = array('id' => $key, 'text' => (zen_not_null($value['symbol_left']) ? $value['symbol_left'] : $value['symbol_right']) );
           
          }
    
          $hidden_get_variables = '';
          reset($_GET);
          while (list($key, $value) = each($_GET)) {
            if ( ($key != 'currency') && ($key != zen_session_name()) && ($key != 'x') && ($key != 'y') ) {
               $hidden_get_variables .= zen_draw_hidden_field($key, $value);
            }
          }
          
    
          require($template->get_template_dir('tpl_header_currencies.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header_currencies.php');
        }
      }
    That code is not standard to Zen Cart and in a way is causing the issue reported...

    Specifically while processing the $_GET parameter data, if that is somehow provided as an array (information on the URI) then that will lead to the reported problem. To prevent it from possibly happening, the following might work:

    Code:
    <?php
    Code:
    // test if box should display
      $show_currencies= false;
    
      // don't display on checkout page:
      if (substr($current_page, 0, 8) != 'checkout') {
        $show_currencies= true;
      }
    
      if ($show_currencies == true) {
        if (isset($currencies) && is_object($currencies)) {
    
          reset($currencies->currencies);
          $currencies_array = array();
          while (list($key, $value) = each($currencies->currencies)) {
           $currencies_array[] = array('id' => $key, 'text' => (zen_not_null($value['symbol_left']) ? $value['symbol_left'] : $value['symbol_right']) );
    
          }
    
          $hidden_get_variables = '';
          reset($_GET);
          while (list($key, $value) = each($_GET)) {
    
    Code:
    if (is_array($key)) continue;
    if ( ($key != 'currency') && ($key != zen_session_name()) && ($key != 'x') && ($key != 'y') ) { $hidden_get_variables .= zen_draw_hidden_field($key, $value); } } require($template->get_template_dir('tpl_header_currencies.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header_currencies.php'); } }


    Was the below portion of the URI on purpose?
    ?selid[201]=1379
    or was it just something someone had tried?

    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Apr 2012
    Posts
    209
    Plugin Contributions
    1

    Default Re: PHP Warning: trim() expects parameter 1 to be string, array given in ....

    Its On Purpose

  8. #8
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: PHP Warning: trim() expects parameter 1 to be string, array given in ....

    Quote Originally Posted by diptimoy View Post
    Its On Purpose
    So then the $key and the $value should be sent through zen_db_prepare_input function so that they can be made into the appropriate string to then be fed to the zen_hidden_field function.

    Not where I can conveniently show the modification easily.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #9
    Join Date
    Apr 2012
    Posts
    209
    Plugin Contributions
    1

    Idea or Suggestion Re: PHP Warning: trim() expects parameter 1 to be string, array given in ....

    Thanks a lot

 

 

Similar Threads

  1. Warning: trim() expects parameter 1 to be string, array given
    By jpietrowiak in forum General Questions
    Replies: 2
    Last Post: 8 Jun 2013, 07:06 PM
  2. 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
  3. v139e PHP Warning: strlen() expects parameter 1 to be string, array given in
    By irishshopper in forum Basic Configuration
    Replies: 4
    Last Post: 7 Mar 2013, 08:06 PM
  4. 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
  5. 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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR