Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Check out error "strlen() expects parameter 1 to be string, array given in general.php on line 163"


vincenthedan

Recommended Posts

Hi guys,

 

right after check out (which goes fine), I get this:

 

Warning: strlen() expects parameter 1 to be string, array given in /home/dismagig/public_html/catalog/includes/functions/general.php on line 163

 

Warning: Cannot modify header information - headers already sent by (output started at /home/dismagig/public_html/catalog/includes/functions/general.php:163) in /home/dismagig/public_html/catalog/includes/functions/general.php on line 33

 

No idea what's going on. I can see the order on the admin panel, but this warning message right after the check out is quite disturbing...

Any solution?

Link to comment
Share on other sites

right after check out (which goes fine), I get this:

 

Warning: strlen() expects parameter 1 to be string, array given in /home/*******/public_html/catalog/includes/functions/general.php on line 163

Might be the bug that was fixed in the section labeled [C] Update product notifications in the update.html that comes with the download of RC2a.

Link to comment
Share on other sites

  • 5 weeks later...

Might be the bug that was fixed in the section labeled [C] Update product notifications in the update.html that comes with the download of RC2a.

 

I am using the latest version of Oscommerce webshop RC2a but still I get the same Warning ( strlen() expects parameter 1 to be string, array given in general.php ).

 

Please some one help.

Link to comment
Share on other sites

I just fond out that the warning will not come agian if you set the Enable GZip Compression to "true" in Admin.

 

But I still dont know why it helps.

 

so if anyone out there know this please help ....

Link to comment
Share on other sites

here is the solution, for this warning:

 

******

 

Warning: strlen() expects parameter 1 to be string, array given in /home/***/public_html/catalog/includes/functions/general.php on line 163

 

***********

 

replace this:


// Return all HTTP GET variables, except those passed as a parameter
 function tep_get_all_get_params($exclude_array = '') {
   global $HTTP_GET_VARS;

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

   $get_url = '';
   if (is_array($HTTP_GET_VARS) && (sizeof($HTTP_GET_VARS) > 0)) {
     reset($HTTP_GET_VARS);
     while (list($key, $value) = each($HTTP_GET_VARS)) {
       if ( (strlen($value) > 0) && ($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array)) && ($key != 'x') && ($key != 'y') ) {
         $get_url .= $key . '=' . rawurlencode(stripslashes($value)) . '&';
       }
     }
   }

   return $get_url;
 }

////


 

By this:


// Return all HTTP GET variables, except those passed as a parameter
 function tep_get_all_get_params($exclude_array = '') {
   global $HTTP_GET_VARS;

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

   $get_url = '';
   if (is_array($HTTP_GET_VARS) && (sizeof($HTTP_GET_VARS) > 0)) {
     reset($HTTP_GET_VARS);
     while (list($key, $value) = each($HTTP_GET_VARS)) {
       if (  is_string($value) && (strlen($value) > 0) && ($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array)) && ($key != 'x') && ($key != 'y') ) {
         $get_url .= $key . '=' . rawurlencode(stripslashes($value)) . '&';
       }
     }
   }

   return $get_url;
 }

////

 

 

************

 

:thumbsup:

Wayand

Link to comment
Share on other sites

While that will fix the immediate problem (passing an array rather than a string to strlen()), it would be better to figure out why you have an array within your $HTTP_GET_VARS/$_GET array. Is this a hack, or a coding error, or is there really supposed to be an array there?

Link to comment
Share on other sites

  • 3 weeks later...

While that will fix the immediate problem (passing an array rather than a string to strlen()), it would be better to figure out why you have an array within your $HTTP_GET_VARS/$_GET array. Is this a hack, or a coding error, or is there really supposed to be an array there?

Was this problem solved beyond a "immediate solution"? I have the same problem and I don't know if to wait for a solution, or to apply the solution posted above?

Thanks.

Link to comment
Share on other sites

  • 2 weeks later...

While that will fix the immediate problem (passing an array rather than a string to strlen()), it would be better to figure out why you have an array within your $HTTP_GET_VARS/$_GET array. Is this a hack, or a coding error, or is there really supposed to be an array there?

 

Since I am a true novice at this (and based upon this comment) I went to the osQuantum Development Forums who offer many many different fixes for OSCommerce. The forums are located here for OSCommerce specifically -

http://forums.osquantum.org/index.php?showforum=3

 

I gave them the ORIG code and the fix given above by wayand. This was their reply...

 

REPLACE WITH

 

// Return all HTTP GET variables, except those passed as a parameter
 function tep_get_all_get_params($exclude_array = '') {
   global $_GET;

   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 ( (strlen($value) > 0) && ($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array)) && ($key != 'x') && ($key != 'y') ) {
         $get_url .= $key . '=' . rawurlencode(stripslashes($value)) . '&';
       }
     }
   }

   return $get_url;
 }

 

 

Hope that helps...

 

BJ

Link to comment
Share on other sites

  • 4 weeks later...

Since I am a true novice at this (and based upon this comment) I went to the osQuantum Development Forums who offer many many different fixes for OSCommerce. The forums are located here for OSCommerce specifically -

http://forums.osquantum.org/index.php?showforum=3

 

I gave them the ORIG code and the fix given above by wayand. This was their reply...

 

REPLACE WITH

 

// Return all HTTP GET variables, except those passed as a parameter
 function tep_get_all_get_params($exclude_array = '') {
   global $_GET;

   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 ( (strlen($value) > 0) && ($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array)) && ($key != 'x') && ($key != 'y') ) {
         $get_url .= $key . '=' . rawurlencode(stripslashes($value)) . '&';
       }
     }
   }

   return $get_url;
 }

 

 

Hope that helps...

 

BJ

 

 

Hello,

Please,help!

The same thing happened to me but mine was on line 33:

 

public_html/includes/functions/general.php on line 33

Link to comment
Share on other sites

What is line 33 in your copy of the file? In standard osC 2.2 RC2a, that line is

    header('Location: ' . $url);

If you're getting "strlen() expects parameter 1..." errors, the closest strlen() is in lines 28 through 30:

      if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { // NONSSL url
       $url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); // Change it to SSL
     }

HTTP_SERVER should be a simple string like "http://yoursite.com". Is HTTP_SERVER properly defined in your includes/configure.php file?

Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...

As MrPhil already stated HTTP_SERVER is a define in catalog/includes/configure.php, PHP 5.3 nor the latest 5.4.6 changes this fact.

Link to comment
Share on other sites

  • 2 months later...

The issue stems from customers checking off the "Notify me of Product updates" at checkout.

 

Here is a replacement for the entire function, with some additional logic. Picked off of the zenCart forums and converted back to OSC:

 

function tep_get_all_get_params($exclude_array = '') {
if (!is_array($exclude_array)) $exclude_array = array();
 $exclude_array = array_merge($exclude_array, array(tep_session_name(), '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 .= tep_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;
}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...