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
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...
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]
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. :)
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');
}
}
Re: PHP Warning: trim() expects parameter 1 to be string, array given in ....
Quote:
Originally Posted by
diptimoy
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:
// 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?
or was it just something someone had tried?
Re: PHP Warning: trim() expects parameter 1 to be string, array given in ....
Re: PHP Warning: trim() expects parameter 1 to be string, array given in ....
Quote:
Originally Posted by
diptimoy
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.
Re: PHP Warning: trim() expects parameter 1 to be string, array given in ....