Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Warning: Variable passed to reset() is not an arra


pmaonline

Recommended Posts

Hi, when i try in admin to enter in customers, it gives me the following error :

 

 

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/erosfarma/admin/customers.php on line 733

 

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/erosfarma/admin/customers.php on line 735

 

Warning: reset() [function.reset]: Passed variable is not an array or object in /home/erosfarma/admin/includes/classes/object_info.php on line 17

 

Warning: Variable passed to each() is not an array or object in /home/erosfarma/admin/includes/classes/object_info.php on line 18

 

 

and when i try to change some customer fields stay empty.

 

 

But this hapens just with the clients that i inserted by csv file, in new customers, this problem desapears..

 

 

THE CODE I USED TO INSERT CUSTOMERS BY CSB IS THIS :

 

 

<?php

require('includes/application_top.php');

if ($HTTP_GET_VARS['action']) {

switch ($HTTP_GET_VARS['action']) {

case 'import':

//retrieve the code for default language from database

$sql_get_default_language = 'SELECT configuration_value FROM ' . TABLE_CONFIGURATION . ' ';

$sql_get_default_language .= 'WHERE configuration_key = "DEFAULT_LANGUAGE"';

$tep_import_res = tep_db_query($sql_get_default_language);

$default_language_array = tep_db_fetch_array ($tep_import_res);

unset ($sql_get_default_language, $tep_import_res);

$sql_get_default_language = 'SELECT languages_id FROM ' . TABLE_LANGUAGES . ' ';

$sql_get_default_laguage .= 'where code = "' . $default_language_array['configuration_value'] . '"';

unset ($default_language_array);

$tep_import_res = tep_db_query($sql_get_default_language);

$default_language_array = tep_db_fetch_array ($tep_import_res);

$default_language_id = $default_language_array['languages_id'];

unset ($default_language_array, $sql_get_default_language);

 

//copy the uploaded CSV file into the images directory.

//it seems like a relevant enough location - the file is

//only temporary after all!

if ( ($csv_to_import != 'none') && ($csv_to_import != '') ) {

$csv_file_location = DIR_FS_CATALOG_IMAGES . $csv_to_import_name;

if (file_exists($csv_file_location)) @unlink($csv_file_location);

copy($csv_to_import, $csv_file_location);

$parse_csv = true;

} else {

$messageStack->add('No file found.', 'erro');

$parse_csv = false;

}

 

if ($parse_csv) {

$csv_fp = fopen ($csv_file_location, "r");

fGetS ($csv_fp, 4096);

$rows = 0;

while ($data = fGetCsv ($csv_fp, 10000, ";")) {

$rows++;

$csv = array();

$csv['first name'] = $data[0];

$csv['last name'] = $data[1];

$csv['contr'] = $data[2];

$csv['client number'] = $data[3];

$csv['email'] = $data[4];

$csv['address'] = $data[5];

$csv['zone'] = $data[6];

$csv['code'] = $data[7];

$csv['phone'] = $data[8];

$csv['newsletter'] = $data[9];

$csv['password'] = $data[10];

$csv['date_inserted'] = 'now()';

$csv['status'] = 1; //hardcoded for now - will change as necessary

 

 

if($csv['password']=="") {

$sql_data_array = array('customers_id' => tep_db_prepare_input($csv['client number']),

'customers_firstname' => tep_db_prepare_input($csv['first name']),

'customers_lastname' => tep_db_prepare_input($csv['last name']),

'customers_email_address' => tep_db_prepare_input($csv['email']),

'customers_default_address_id' => tep_db_prepare_input($csv['client number']),

'customers_telephone' => tep_db_prepare_input($csv['phone']),

'customers_newsletter' => tep_db_prepare_input($csv['newsletter'])

);

}

else {

$sql_data_array = array('customers_id' => tep_db_prepare_input($csv['client number']),

'customers_firstname' => tep_db_prepare_input($csv['first name']),

'customers_lastname' => tep_db_prepare_input($csv['last name']),

'customers_email_address' => tep_db_prepare_input($csv['email']),

'customers_default_address_id' => tep_db_prepare_input($csv['client number']),

'customers_telephone' => tep_db_prepare_input($csv['phone']),

'customers_password' => tep_db_prepare_input(tep_encrypt_password($csv['password'])),

'customers_newsletter' => tep_db_prepare_input($csv['newsletter'])

);

 

}

 

$res=tep_db_query("SELECT customers_id FROM customers WHERE customers_id=".$csv['client number'].";");

$n=tep_db_num_rows($res);

 

// INSERT

if(!$n) {

tep_db_perform('customers', $sql_data_array);

$inserted_customer_id = $csv['client number'];

unset($sql_data_array);

$sql_data_array = array('address_book_id' => tep_db_prepare_input($csv['client number']),

'customers_id' => tep_db_prepare_input($inserted_customer_id),

'entry_firstname' => tep_db_prepare_input($csv['first name']),

'entry_lastname' => tep_db_prepare_input($csv['last name']),

'entry_street_address' => tep_db_prepare_input($csv['address']),

'entry_suburb' => tep_db_prepare_input($csv['zone']),

'entry_postcode' => tep_db_prepare_input($csv['code']),

 

'entry_country_id' => tep_db_prepare_input(1),

);

tep_db_perform('address_book', $sql_data_array);

}

 

//UPDATE

else {

tep_db_perform('customers', $sql_data_array, 'update', 'customers_id='.$csv['client number'].'');

unset($sql_data_array);

$sql_data_array = array('address_book_id' => tep_db_prepare_input($csv['client number']),

 

'entry_firstname' => tep_db_prepare_input($csv['first name']),

'entry_lastname' => tep_db_prepare_input($csv['last name']),

'entry_street_address' => tep_db_prepare_input($csv['address']),

'entry_suburb' => tep_db_prepare_input($csv['zone']),

'entry_postcode' => tep_db_prepare_input($csv['code']),

 

'entry_country_id' => tep_db_prepare_input(1),

 

);

tep_db_perform('address_book', $sql_data_array, 'update', 'customers_id='.$csv['client number'].'');

 

}

unset($sql_data_array, $csv);

}

fclose ($csv_fp);

@unlink ($csv_file_location);

 

}

}

}

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

<script language="javascript" src="includes/general.js"></script>

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">

<div id="spiffycalendar" class="text"></div>

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="2" cellpadding="2">

<tr>

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

</table></td>

<!-- body_text //-->

<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td><font face=verdana size=2><b>Import Clients</b></td>

<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td>

 

<?php

if ($HTTP_GET_VARS['action']) {

switch ($HTTP_GET_VARS['action']) {

case 'import':

?>

<font face=verdana size=2><b><?php echo $rows; ?></b> clients imported.</font>

 

<?php

}

} else {

echo tep_draw_form ('import', 'clients.php', 'action=import', 'post', 'enctype="multipart/form-data"');

?>

<font face=verdana size=2>File:<br>

<?php echo tep_draw_file_field('csv_to_import', true); ?><br>

<font face=verdana size=2><br>File must be in csv format.<br><br>

<?php echo tep_image_submit('button_save.gif', IMAGE_SAVE); ?>

 

 

 

<?php

}

?>

</td>

</tr>

</table></td>

<!-- body_text_eof //-->

</tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

 

 

 

What should i do ????

 

Thanks for your help.

Link to comment
Share on other sites

OK, i just found the solution but i need someone to help doing a query.

 

I just saw that when i insert customers by csv i didn?t insert any information in table CUSTOMERS_INFO so now i just need to SELECT data in table ADDRESS_BOOK and insert it in the CUSTOMERS_INFO table.

 

 

hOW TO DO THIS QUERY???

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...