Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Warning: implode() [function.implode]: Bad arguments


ammu_omni

Recommended Posts

Hi,

 

I got this warning in my oscommerce admin panel and i don't know what is the problem and how it happen? I cannot view my products in admin now. I have huge amount of data.

 

So someone please help me in resolving this. Please!!!!!!!

 

I'm using oscommerce v2.2Rc2a.

 

Here is my warning.

 

Warning: implode() [function.implode]: Bad arguments. in D:\home\Default\omnitrack.co.nz\htdocs\admin\includes\application_top.php on line 199

 

 

Here is my code..,

 

<?php

/*

$Id: application_top.php 1833 2008-01-30 22:03:30Z hpdl $

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

Copyright © 2008 osCommerce

Released under the GNU General Public License

*/

// Start the clock for the page parse time log

define('PAGE_PARSE_START_TIME', microtime());

// Set the level of error reporting

error_reporting(E_ALL & ~E_NOTICE);

// check support for register_globals

if (function_exists('ini_get') && (ini_get('register_globals') == false) && (PHP_VERSION < 4.3) ) {

exit('Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory. Please use PHP 4.3+ if register_globals cannot be enabled on the server.');

}

// Set the local configuration parameters - mainly for developers

if (file_exists('includes/local/configure.php')) include('includes/local/configure.php');

// Include application configuration parameters

require('includes/configure.php');

// Define the project version

define('PROJECT_VERSION', 'osCommerce Online Merchant v2.2 RC2a');

// some code to solve compatibility issues

require(DIR_WS_FUNCTIONS . 'compatibility.php');

// set php_self in the local scope

$PHP_SELF = (isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME']);

// Used in the "Backup Manager" to compress backups

define('LOCAL_EXE_GZIP', '/usr/bin/gzip');

define('LOCAL_EXE_GUNZIP', '/usr/bin/gunzip');

define('LOCAL_EXE_ZIP', '/usr/local/bin/zip');

define('LOCAL_EXE_UNZIP', '/usr/local/bin/unzip');

// include the list of project filenames

require(DIR_WS_INCLUDES . 'filenames.php');

// include the list of project database tables

require(DIR_WS_INCLUDES . 'database_tables.php');

// customization for the design layout

define('BOX_WIDTH', 125); // how wide the boxes should be in pixels (default: 125)

// Define how do we update currency exchange rates

// Possible values are 'oanda' 'xe' or ''

define('CURRENCY_SERVER_PRIMARY', 'oanda');

define('CURRENCY_SERVER_BACKUP', 'xe');

// include the database functions

require(DIR_WS_FUNCTIONS . 'database.php');

// make a connection to the database... now

tep_db_connect() or die('Unable to connect to database server!');

// set application wide parameters

$configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION);

while ($configuration = tep_db_fetch_array($configuration_query)) {

define($configuration['cfgKey'], $configuration['cfgValue']);

}

// define our general functions used application-wide

require(DIR_WS_FUNCTIONS . 'general.php');

require(DIR_WS_FUNCTIONS . 'html_output.php');

// initialize the logger class

require(DIR_WS_CLASSES . 'logger.php');

// include shopping cart class

require(DIR_WS_CLASSES . 'shopping_cart.php');

// check to see if php implemented session management functions - if not, include php3/php4 compatible session class

if (!function_exists('session_start')) {

define('PHP_SESSION_NAME', 'osCAdminID');

define('PHP_SESSION_PATH', '/');

define('PHP_SESSION_SAVE_PATH', SESSION_WRITE_DIRECTORY);

include(DIR_WS_CLASSES . 'sessions.php');

}

// define how the session functions will be used

require(DIR_WS_FUNCTIONS . 'sessions.php');

// set the session name and save path

tep_session_name('osCAdminID');

tep_session_save_path(SESSION_WRITE_DIRECTORY);

// set the session cookie parameters

if (function_exists('session_set_cookie_params')) {

session_set_cookie_params(0, DIR_WS_ADMIN);

} elseif (function_exists('ini_set')) {

ini_set('session.cookie_lifetime', '0');

ini_set('session.cookie_path', DIR_WS_ADMIN);

}

// lets start our session

tep_session_start();

if ( (PHP_VERSION >= 4.3) && function_exists('ini_get') && (ini_get('register_globals') == false) ) {

extract($_SESSION, EXTR_OVERWRITE+EXTR_REFS);

}

// set the language

if (!tep_session_is_registered('language') || isset($HTTP_GET_VARS['language'])) {

if (!tep_session_is_registered('language')) {

tep_session_register('language');

tep_session_register('languages_id');

}

include(DIR_WS_CLASSES . 'language.php');

$lng = new language();

if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) {

$lng->set_language($HTTP_GET_VARS['language']);

} else {

$lng->get_browser_language();

}

$language = $lng->language['directory'];

$languages_id = $lng->language['id'];

}

// redirect to login page if administrator is not yet logged in

if (!tep_session_is_registered('admin')) {

$redirect = false;

$current_page = basename($PHP_SELF);

if ($current_page != FILENAME_LOGIN) {

if (!tep_session_is_registered('redirect_origin')) {

tep_session_register('redirect_origin');

$redirect_origin = array('page' => $current_page,

'get' => $HTTP_GET_VARS);

}

$redirect = true;

}

if ($redirect == true) {

tep_redirect(tep_href_link(FILENAME_LOGIN));

}

unset($redirect);

}

// include the language translations

require(DIR_WS_LANGUAGES . $language . '.php');

$current_page = basename($PHP_SELF);

if (file_exists(DIR_WS_LANGUAGES . $language . '/' . $current_page)) {

include(DIR_WS_LANGUAGES . $language . '/' . $current_page);

}

// define our localization functions

require(DIR_WS_FUNCTIONS . 'localization.php');

// Include validation functions (right now only email address)

require(DIR_WS_FUNCTIONS . 'validations.php');

// setup our boxes

require(DIR_WS_CLASSES . 'table_block.php');

require(DIR_WS_CLASSES . 'box.php');

// initialize the message stack for output messages

require(DIR_WS_CLASSES . 'message_stack.php');

$messageStack = new messageStack;

// split-page-results

require(DIR_WS_CLASSES . 'split_page_results.php');

// entry/item info classes

require(DIR_WS_CLASSES . 'object_info.php');

// email classes

require(DIR_WS_CLASSES . 'mime.php');

require(DIR_WS_CLASSES . 'email.php');

// file uploading class

require(DIR_WS_CLASSES . 'upload.php');

// calculate category path

if (isset($HTTP_GET_VARS['cPath'])) {

$cPath = $HTTP_GET_VARS['cPath'];

} else {

$cPath = '';

}

if (tep_not_null($cPath)) {

$cPath_array = tep_parse_category_path($cPath);

$cPath = implode('_', $cPath_array);

$current_category_id = $cPath_array[(sizeof($cPath_array)-1)];

} else {

$current_category_id = 0;

}

// default open navigation box

if (!tep_session_is_registered('selected_box')) {

tep_session_register('selected_box');

$selected_box = 'configuration';

}

if (isset($HTTP_GET_VARS['selected_box'])) {

$selected_box = $HTTP_GET_VARS['selected_box'];

}

// the following cache blocks are used in the Tools->Cache section

// ('language' in the filename is automatically replaced by available languages)

$cache_blocks = array(array('title' => TEXT_CACHE_CATEGORIES, 'code' => 'categories', 'file' => 'categories_box-language.cache', 'multiple' => true),

array('title' => TEXT_CACHE_MANUFACTURERS, 'code' => 'manufacturers', 'file' => 'manufacturers_box-language.cache', 'multiple' => true),

array('title' => TEXT_CACHE_ALSO_PURCHASED, 'code' => 'also_purchased', 'file' => 'also_purchased-language.cache', 'multiple' => true)

);

// check if a default currency is set

if (!defined('DEFAULT_CURRENCY')) {

$messageStack->add(ERROR_NO_DEFAULT_CURRENCY_DEFINED, 'error');

}

// check if a default language is set

if (!defined('DEFAULT_LANGUAGE')) {

$messageStack->add(ERROR_NO_DEFAULT_LANGUAGE_DEFINED, 'error');

}

if (function_exists('ini_get') && ((bool)ini_get('file_uploads') == false) ) {

$messageStack->add(WARNING_FILE_UPLOADS_DISABLED, 'warning');

}

?>

Link to comment
Share on other sites

1. Next time please put [ code ] tags around your code. It's very difficult to read when lines are wrapped around like that.

2. There don't appear to be 199 lines in this file. I suspect you picked up the wrong application_top.php file (perhaps the non-admin version).

3. There is one "implode" call at around line 148 or so. It would appear that the variable $cPath_array is not a proper array, if this is in fact the one with the error (but see (2)).

Link to comment
Share on other sites

1. Next time please put [ code ] tags around your code. It's very difficult to read when lines are wrapped around like that.

2. There don't appear to be 199 lines in this file. I suspect you picked up the wrong application_top.php file (perhaps the non-admin version).

3. There is one "implode" call at around line 148 or so. It would appear that the variable $cPath_array is not a proper array, if this is in fact the one with the error (but see (2)).

 

Hi MrPhil,

 

Sorry for pasting the whole file.

 

I have attached the file this time plz check and reply

 

It appears when i try to click on my Categories/Products in admin.

 

this is the block of code

 

// calculate category path

if (isset($HTTP_GET_VARS['cPath'])) {

$cPath = $HTTP_GET_VARS['cPath'];

} else {

$cPath = '';

}

if (tep_not_null($cPath)) {

$cPath_array = tep_parse_category_path($cPath);

$cPath = implode('_', $cPath_array);

$current_category_id = $cPath_array[(sizeof($cPath_array)-1)];

} else {

$current_category_id = 0;

}

 

 

Error shows on this line.

 

$cPath = implode('_', $cPath_array);

application_top - org.php

Link to comment
Share on other sites

First try to see what tep_parse_category_path($cPath) returns

 

do:

 


$cPath_array = tep_parse_category_path($cPath);

var_dump($cPath_array);

$cPath = implode('_', $cPath_array);
$current_category_id = $cPath_array[(sizeof($cPath_array)-1)];


 

Is $cPath_array an array?

Check out the great Alternative Administration System addon for osCommerce!

Link to comment
Share on other sites

First try to see what tep_parse_category_path($cPath) returns do:
 $cPath_array = tep_parse_category_path($cPath); var_dump($cPath_array); $cPath = implode('_', $cPath_array); $current_category_id = $cPath_array[(sizeof($cPath_array)-1)]; 

Is $cPath_array an array?

 

Hi John Barounis,

 

Thank You for your reply.

 

I tried to add the code it returns NULL but the warning is still there and i can't able to view the products under categories/product option.

 

Warning from my admin page after adding you line of code.

 

NULL

Warning: implode() [function.implode]: Bad arguments. in D:\home\Default\omnitrack.co.nz\htdocs\admin\includes\application_top.php on line 202

 

My Original Code:

 

// calculate category path

if (isset($HTTP_GET_VARS['cPath'])) {

$cPath = $HTTP_GET_VARS['cPath'];

} else {

$cPath = '';

}

if (tep_not_null($cPath)) {

$cPath_array = tep_parse_category_path($cPath);

$cPath = implode('_', $cPath_array);

$current_category_id = $cPath_array[(sizeof($cPath_array)-1)];

} else {

$current_category_id = 0;

}

Link to comment
Share on other sites

The implode function needs an array as an argument.

 

So you get this warning because

 

tep_parse_category_path($cPath);

 

returns null not an array

 

SO second thing to be done is ti check the $cPath variable and check the tep_parse_category_path() function

Check out the great Alternative Administration System addon for osCommerce!

Link to comment
Share on other sites

The implode function needs an array as an argument.

 

So you get this warning because

 

tep_parse_category_path($cPath);

 

returns null not an array

 

SO second thing to be done is ti check the $cPath variable and check the tep_parse_category_path() function

 

Hi John Barounis,

 

Thanks for your reply.

 

But i'm new to osCommerce I don't where to check those $cpath and tep_parse_category_path().

 

Can you please tell me where check those and what to do?

 

Please....

Link to comment
Share on other sites

On the line before the implode that's exploding (sorry, couldn't resist), it's telling you that $cPath_array is NULL instead of a real array. Something is wrong with the tep_parse_category_path() call if it's returning a NULL for a $cPath argument that is not null or empty ''. How about backing up one more line and printing out the original $cPath with either var_dump($cPath); or print "cPath = '$cPath'<br />\n";.

 

Where are you getting line 202 (originally 199) if the file only had about 179 lines? If it's reporting that $cPath_array is NULL, that must be the right file, but I'm really concerned as to why the wrong line number if you're in the right file.

 

You're still not using [ code ] tags around your code.

Link to comment
Share on other sites

On the line before the implode that's exploding (sorry, couldn't resist), it's telling you that $cPath_array is NULL instead of a real array. Something is wrong with the tep_parse_category_path() call if it's returning a NULL for a $cPath argument that is not null or empty ''. How about backing up one more line and printing out the original $cPath with either var_dump($cPath); or print "cPath = '$cPath'<br />\n";.

 

Where are you getting line 202 (originally 199) if the file only had about 179 lines? If it's reporting that $cPath_array is NULL, that must be the right file, but I'm really concerned as to why the wrong line number if you're in the right file.

 

You're still not using [ code ] tags around your code.

 

Hi John Barounis,

 

Thanks for you reply.

 

I've checked the general .php file for the $cpath and tep_parse_category_path(). In the tep_parse_category_path() function cpath was not returned so i modified the code now my category/products options are working in admin. I don't know how it's stated showing error afer 2 years but now it is fine.

 

The code i added in general.php file is

 

return $tmp_array

}

 

But in osCommerce Admin - Modules - Payment, Shipping, Order Total all the three modules are showing a new warning message. That's wired.

 

Now it is getting bigger

 

This is the warning message on top of payment module..,

 

Warning: include(D:/home/Default/omnitrack.co.nz/htdocs/includes/languages/english/modules/payment/on_account.php) [function.include]: failed to open stream: No such file or directory in D:\home\Default\omnitrack.co.nz\htdocs\admin\modules.php on line 136

 

Warning: include() [function.include]: Failed opening 'D:/home/Default/omnitrack.co.nz/htdocs/includes/languages/english/modules/payment/on_account.php' for inclusion (include_path='.;C:\php5\pear') in D:\home\Default\omnitrack.co.nz\htdocs\admin\modules.php on line 136

 

I've attached the modules.php file with this.

 

can you please help me with this

modules.php

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...