Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Error: Warning: mysql_fetch_array():


sac9829

Recommended Posts

Hi Does anybody know how to fix the following problem:

 

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sac9829/sacotech-www/catalog/admin/includes/functions/database.php on line 99

 

 

I have tried uploading the default database page by I still reievice the following error.

 

 

Any ideas

Link to comment
Share on other sites

Check the code that is calling the function. What the error is saying is that whatever $dbquery is set to is not a valid mysql resource. Where is the function being called from? Check to make sure you have the initial query configured properly. $dbquery should contain the result of the query.

Link to comment
Share on other sites

Sorry Im need with php and not sure which bit of code I need to check

 

Below is my code

 

<?php
/*
 $Id: database.php,v 1.23 2003/06/20 00:18:30 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') {
   global $$link;

   if (USE_PCONNECT == 'true') {
     $$link = mysql_pconnect($server, $username, $password);
   } else {
     $$link = mysql_connect($server, $username, $password);
   }

   if ($$link) mysql_select_db($database);

   return $$link;
 }

 function tep_db_close($link = 'db_link') {
   global $$link;

   return mysql_close($$link);
 }

 function tep_db_error($query, $errno, $error) { 
   die('<font color="#000000"><b>' . $errno . ' - ' . $error . '<br><br>' . $query . '<br><br><small><font color="#ff0000">[TEP STOP]</font></small><br><br></b></font>');
 }

 function tep_db_query($query, $link = 'db_link') {
   global $$link, $logger;

   if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {
     if (!is_object($logger)) $logger = new logger;
     $logger->write($query, 'QUERY');
   }

   $result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error());

   if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {
     if (mysql_error()) $logger->write(mysql_error(), 'ERROR');
   }

   return $result;
 }

 function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $link = 'db_link') {
   reset($data);
   if ($action == 'insert') {
     $query = 'insert into ' . $table . ' (';
     while (list($columns, ) = each($data)) {
       $query .= $columns . ', ';
     }
     $query = substr($query, 0, -2) . ') values (';
     reset($data);
     while (list(, $value) = each($data)) {
       switch ((string)$value) {
         case 'now()':
           $query .= 'now(), ';
           break;
         case 'null':
           $query .= 'null, ';
           break;
         default:
           $query .= '\'' . tep_db_input($value) . '\', ';
           break;
       }
     }
     $query = substr($query, 0, -2) . ')';
   } elseif ($action == 'update') {
     $query = 'update ' . $table . ' set ';
     while (list($columns, $value) = each($data)) {
       switch ((string)$value) {
         case 'now()':
           $query .= $columns . ' = now(), ';
           break;
         case 'null':
           $query .= $columns .= ' = null, ';
           break;
         default:
           $query .= $columns . ' = \'' . tep_db_input($value) . '\', ';
           break;
       }
     }
     $query = substr($query, 0, -2) . ' where ' . $parameters;
   }

   return tep_db_query($query, $link);
 }

 function tep_db_fetch_array($db_query) {
   return mysql_fetch_array($db_query, MYSQL_ASSOC);
 }

 function tep_db_result($result, $row, $field = '') {
   return mysql_result($result, $row, $field);
 }

 function tep_db_num_rows($db_query) {
   return mysql_num_rows($db_query);
 }

 function tep_db_data_seek($db_query, $row_number) {
   return mysql_data_seek($db_query, $row_number);
 }

 function tep_db_insert_id() {
   return mysql_insert_id();
 }

 function tep_db_free_result($db_query) {
   return mysql_free_result($db_query);
 }

 function tep_db_fetch_fields($db_query) {
   return mysql_fetch_field($db_query);
 }

 function tep_db_output($string) {
   return htmlspecialchars($string);
 }

 function tep_db_input($string) {
   return addslashes($string);
 }

 function tep_db_prepare_input($string) {
   if (is_string($string)) {
     return trim(stripslashes($string));
   } elseif (is_array($string)) {
     reset($string);
     while (list($key, $value) = each($string)) {
       $string[$key] = tep_db_prepare_input($value);
     }
     return $string;
   } else {
     return $string;
   }
 }
?>

 

Where should I look!

Link to comment
Share on other sites

Here is my code:

 

<?php

/*

 $Id: customers.php,v 1.82 2003/06/30 13:54:14 dgw_ Exp $

 

 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com

 

 Copyright (c) 2003 osCommerce

 

 Released under the GNU General Public License

*/

 

 require('includes/application_top.php');

 

 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 

 $error = false;

 $processed = false;

 

 if (tep_not_null($action)) {

   switch ($action) {

     case 'update':

       $customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);

       $customers_firstname = tep_db_prepare_input($HTTP_POST_VARS['customers_firstname']);

       $customers_lastname = tep_db_prepare_input($HTTP_POST_VARS['customers_lastname']);

       $customers_email_address = tep_db_prepare_input($HTTP_POST_VARS['customers_email_address']);

       $customers_telephone = tep_db_prepare_input($HTTP_POST_VARS['customers_telephone']);

       $customers_fax = tep_db_prepare_input($HTTP_POST_VARS['customers_fax']);

       $customers_newsletter = tep_db_prepare_input($HTTP_POST_VARS['customers_newsletter']);

 $multiple_groups_query = tep_db_query("select distinct customers_group_id from " . TABLE_PRODUCTS_GROUPS . " ");

while ($group_ids = tep_db_fetch_array($multiple_groups_query)) {

 $multiple_customers_query = tep_db_query("select distinct customers_group_id from " . TABLE_CUSTOMERS . " where customers_group_id = " . $group_ids['customers_group_id'] . " ");

 if (!($multiple_groups = tep_db_fetch_array($multiple_customers_query))) {

   tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $group_ids['customers_group_id'] . "'");

 }

}

 

$customers_group_name = tep_db_prepare_input($HTTP_POST_VARS['customers_group_name']);

$counter = 0;

$assigned = 0;

 

$customers_group_name_query = tep_db_query("select distinct customers_group_name, customers_group_id from " . TABLE_CUSTOMERS . " order by customers_group_id");

 

while ($group_name_check = tep_db_fetch_array($customers_group_name_query)) {

$counter = $group_name_check['customers_group_id'];

 

 if ($group_name_check['customers_group_name'] == $customers_group_name) {

   $customers_group_id = $group_name_check['customers_group_id'];

$assigned = 1;

   break;

 }

   

 ++$counter;

}

 

if ($assigned == 0) {

 $customers_group_id = $counter;

}

 

       $customers_gender = tep_db_prepare_input($HTTP_POST_VARS['customers_gender']);

       $customers_dob = tep_db_prepare_input($HTTP_POST_VARS['customers_dob']);

 

       $default_address_id = tep_db_prepare_input($HTTP_POST_VARS['default_address_id']);

       $entry_street_address = tep_db_prepare_input($HTTP_POST_VARS['entry_street_address']);

       $entry_suburb = tep_db_prepare_input($HTTP_POST_VARS['entry_suburb']);

       $entry_postcode = tep_db_prepare_input($HTTP_POST_VARS['entry_postcode']);

       $entry_city = tep_db_prepare_input($HTTP_POST_VARS['entry_city']);

       $entry_country_id = tep_db_prepare_input($HTTP_POST_VARS['entry_country_id']);

 

       $entry_company = tep_db_prepare_input($HTTP_POST_VARS['entry_company']);

       $entry_state = tep_db_prepare_input($HTTP_POST_VARS['entry_state']);

       if (isset($HTTP_POST_VARS['entry_zone_id'])) $entry_zone_id = tep_db_prepare_input($HTTP_POST_VARS['entry_zone_id']);

 

       if (strlen($customers_firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {

         $error = true;

         $entry_firstname_error = true;

       } else {

         $entry_firstname_error = false;

       }

 

       if (strlen($customers_lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {

         $error = true;

         $entry_lastname_error = true;

       } else {

         $entry_lastname_error = false;

       }

 

       if (ACCOUNT_DOB == 'true') {

         if (checkdate(substr(tep_date_raw($customers_dob), 4, 2), substr(tep_date_raw($customers_dob), 6, 2), substr(tep_date_raw($customers_dob), 0, 4))) {

           $entry_date_of_birth_error = false;

         } else {

           $error = true;

           $entry_date_of_birth_error = true;

         }

       }

 

       if (strlen($customers_email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {

         $error = true;

         $entry_email_address_error = true;

       } else {

         $entry_email_address_error = false;

       }

 

       if (!tep_validate_email($customers_email_address)) {

         $error = true;

         $entry_email_address_check_error = true;

       } else {

         $entry_email_address_check_error = false;

       }

 

       if (strlen($entry_street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {

         $error = true;

         $entry_street_address_error = true;

       } else {

         $entry_street_address_error = false;

       }

 

       if (strlen($entry_postcode) < ENTRY_POSTCODE_MIN_LENGTH) {

         $error = true;

         $entry_post_code_error = true;

       } else {

         $entry_post_code_error = false;

       }

 

       if (strlen($entry_city) < ENTRY_CITY_MIN_LENGTH) {

         $error = true;

         $entry_city_error = true;

       } else {

         $entry_city_error = false;

       }

 

       if ($entry_country_id == false) {

         $error = true;

         $entry_country_error = true;

       } else {

         $entry_country_error = false;

       }

 

       if (ACCOUNT_STATE == 'true') {

         if ($entry_country_error == true) {

           $entry_state_error = true;

         } else {

           $zone_id = 0;

           $entry_state_error = false;

           $check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . (int)$entry_country_id . "'");

           $check_value = tep_db_fetch_array($check_query);

           $entry_state_has_zones = ($check_value['total'] > 0);

           if ($entry_state_has_zones == true) {

             $zone_query = tep_db_query("select zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$entry_country_id . "' and zone_name = '" . tep_db_input($entry_state) . "'");

             if (tep_db_num_rows($zone_query) == 1) {

               $zone_values = tep_db_fetch_array($zone_query);

               $entry_zone_id = $zone_values['zone_id'];

             } else {

               $error = true;

               $entry_state_error = true;

             }

           } else {

             if ($entry_state == false) {

               $error = true;

               $entry_state_error = true;

             }

           }

        }

     }

 

     if (strlen($customers_telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {

       $error = true;

       $entry_telephone_error = true;

     } else {

       $entry_telephone_error = false;

     }

 

     $check_email = tep_db_query("select customers_email_address from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($customers_email_address) . "' and customers_id != '" . (int)$customers_id . "'");

     if (tep_db_num_rows($check_email)) {

       $error = true;

       $entry_email_address_exists = true;

     } else {

       $entry_email_address_exists = false;

     }

 

     if ($error == false) {

 

       $sql_data_array = array('customers_firstname' => $customers_firstname,

                               'customers_lastname' => $customers_lastname,

                               'customers_email_address' => $customers_email_address,

                               'customers_telephone' => $customers_telephone,

                               'customers_fax' => $customers_fax,

                               'customers_newsletter' => $customers_newsletter,

       'customers_group_id' => $customers_group_id,

       'customers_group_name' => $customers_group_name);

 

       if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $customers_gender;

       if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($customers_dob);

 

       tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "'");

 

       tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int)$customers_id . "'");

 

       if ($entry_zone_id > 0) $entry_state = '';

 

       $sql_data_array = array('entry_firstname' => $customers_firstname,

                               'entry_lastname' => $customers_lastname,

                               'entry_street_address' => $entry_street_address,

                               'entry_postcode' => $entry_postcode,

                               'entry_city' => $entry_city,

                               'entry_country_id' => $entry_country_id);

 

       if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $entry_company;

       if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $entry_suburb;

 

       if (ACCOUNT_STATE == 'true') {

         if ($entry_zone_id > 0) {

           $sql_data_array['entry_zone_id'] = $entry_zone_id;

           $sql_data_array['entry_state'] = '';

         } else {

           $sql_data_array['entry_zone_id'] = '0';

           $sql_data_array['entry_state'] = $entry_state;

         }

       }

 

       tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$default_address_id . "'");

 

       tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $customers_id));

 

       } else if ($error == true) {

         $cInfo = new objectInfo($HTTP_POST_VARS);

         $processed = true;

       }

 

       break;

     case 'deleteconfirm':

       $customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);

 

       if (isset($HTTP_POST_VARS['delete_reviews']) && ($HTTP_POST_VARS['delete_reviews'] == 'on')) {

         $reviews_query = tep_db_query("select reviews_id from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers_id . "'");

         while ($reviews = tep_db_fetch_array($reviews_query)) {

           tep_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$reviews['reviews_id'] . "'");

         }

 

         tep_db_query("delete from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers_id . "'");

       } else {

         tep_db_query("update " . TABLE_REVIEWS . " set customers_id = null where customers_id = '" . (int)$customers_id . "'");

       }

 $multiple_groups_query = tep_db_query("select distinct customers_group_id from " . TABLE_PRODUCTS_GROUPS . " ");

while ($group_ids = tep_db_fetch_array($multiple_groups_query)) {

 $multiple_customers_query = tep_db_query("select distinct customers_group_id from " . TABLE_CUSTOMERS . " where customers_group_id = " . $group_ids['customers_group_id'] . " ");

 if (!($multiple_groups = tep_db_fetch_array($multiple_customers_query))) {

   tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $group_ids['customers_group_id'] . "'");

 }

}

 

       tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "'");

       tep_db_query("delete from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");

       tep_db_query("delete from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customers_id . "'");

       tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customers_id . "'");

       tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customers_id . "'");

       tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where customer_id = '" . (int)$customers_id . "'");

 

       tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action'))));

       break;

     default:

       $customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_group_name, c.customers_default_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . $HTTP_GET_VARS['cID'] . "'");

 $existing_customers_query = tep_db_query("select distinct customers_group_name from " . TABLE_CUSTOMERS . " order by customers_group_id ");

       $customers = tep_db_fetch_array($customers_query);

       $cInfo = new objectInfo($customers);

   }

 }

?>

<!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>

<?php

 if ($action == 'edit' || $action == 'update') {

?>

<script language="javascript"><!--

 

function check_form() {

 var error = 0;

 var error_message = "<?php echo JS_ERROR; ?>";

 

 var customers_firstname = document.customers.customers_firstname.value;

 var customers_lastname = document.customers.customers_lastname.value;

<?php if (ACCOUNT_COMPANY == 'true') echo 'var entry_company = document.customers.entry_company.value;' . "\n"; ?>

<?php if (ACCOUNT_DOB == 'true') echo 'var customers_dob = document.customers.customers_dob.value;' . "\n"; ?>

 var customers_email_address = document.customers.customers_email_address.value;

 var entry_street_address = document.customers.entry_street_address.value;

 var entry_postcode = document.customers.entry_postcode.value;

 var entry_city = document.customers.entry_city.value;

 var customers_telephone = document.customers.customers_telephone.value;

 

<?php if (ACCOUNT_GENDER == 'true') { ?>

 if (document.customers.customers_gender[0].checked || document.customers.customers_gender[1].checked) {

 } else {

   error_message = error_message + "<?php echo JS_GENDER; ?>";

   error = 1;

 }

<?php } ?>

 

 if (customers_firstname == "" || customers_firstname.length < <?php echo ENTRY_FIRST_NAME_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_FIRST_NAME; ?>";

   error = 1;

 }

 

 if (customers_lastname == "" || customers_lastname.length < <?php echo ENTRY_LAST_NAME_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_LAST_NAME; ?>";

   error = 1;

 }

 

<?php if (ACCOUNT_DOB == 'true') { ?>

 if (customers_dob == "" || customers_dob.length < <?php echo ENTRY_DOB_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_DOB; ?>";

   error = 1;

 }

<?php } ?>

 

 if (customers_email_address == "" || customers_email_address.length < <?php echo ENTRY_EMAIL_ADDRESS_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_EMAIL_ADDRESS; ?>";

   error = 1;

 }

 

 if (entry_street_address == "" || entry_street_address.length < <?php echo ENTRY_STREET_ADDRESS_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_ADDRESS; ?>";

   error = 1;

 }

 

 if (entry_postcode == "" || entry_postcode.length < <?php echo ENTRY_POSTCODE_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_POST_CODE; ?>";

   error = 1;

 }

 

 if (entry_city == "" || entry_city.length < <?php echo ENTRY_CITY_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_CITY; ?>";

   error = 1;

 }

 

<?php

 if (ACCOUNT_STATE == 'true') {

?>

 if (document.customers.elements['entry_state'].type != "hidden") {

   if (document.customers.entry_state.value == '' || document.customers.entry_state.value.length < <?php echo ENTRY_STATE_MIN_LENGTH; ?> ) {

      error_message = error_message + "<?php echo JS_STATE; ?>";

      error = 1;

   }

 }

<?php

 }

?>

 

 if (document.customers.elements['entry_country_id'].type != "hidden") {

   if (document.customers.entry_country_id.value == 0) {

     error_message = error_message + "<?php echo JS_COUNTRY; ?>";

     error = 1;

   }

 }

 

 if (customers_telephone == "" || customers_telephone.length < <?php echo ENTRY_TELEPHONE_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_TELEPHONE; ?>";

   error = 1;

 }

 

 if (error == 1) {

   alert(error_message);

   return false;

 } else {

   return true;

 }

}

//--></script>

<?php

 }

?>

</head>

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

<!-- 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">

<?php

 if ($action == 'edit' || $action == 'update') {

   $newsletter_array = array(array('id' => '1', 'text' => ENTRY_NEWSLETTER_YES),

                             array('id' => '0', 'text' => ENTRY_NEWSLETTER_NO));

?>

     <tr>

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

         <tr>

           <td class="pageHeading"><?php echo HEADING_TITLE; ?></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 echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

     </tr>

     <tr><?php echo tep_draw_form('customers', FILENAME_CUSTOMERS, tep_get_all_get_params(array('action')) . 'action=update', 'post', 'onSubmit="return check_form();"') . tep_draw_hidden_field('default_address_id', $cInfo->customers_default_address_id); ?>

       <td class="formAreaTitle"><?php echo CATEGORY_PERSONAL; ?></td>

     </tr>

     <tr>

       <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">

<?php

   if (ACCOUNT_GENDER == 'true') {

?>

         <tr>

           <td class="main"><?php echo ENTRY_GENDER; ?></td>

           <td class="main">

<?php

   if ($error == true) {

     if ($entry_gender_error == true) {

       echo tep_draw_radio_field('customers_gender', 'm', false, $cInfo->customers_gender) . '  ' . MALE . '  ' . tep_draw_radio_field('customers_gender', 'f', false, $cInfo->customers_gender) . '  ' . FEMALE . ' ' . ENTRY_GENDER_ERROR;

     } else {

       echo ($cInfo->customers_gender == 'm') ? MALE : FEMALE;

       echo tep_draw_hidden_field('customers_gender');

     }

   } else {

     echo tep_draw_radio_field('customers_gender', 'm', false, $cInfo->customers_gender) . '  ' . MALE . '  ' . tep_draw_radio_field('customers_gender', 'f', false, $cInfo->customers_gender) . '  ' . FEMALE;

   }

?></td>

         </tr>

<?php

   }

?>

         <tr>

           <td class="main"><?php echo ENTRY_FIRST_NAME; ?></td>

           <td class="main">

<?php

 if ($error == true) {

   if ($entry_firstname_error == true) {

     echo tep_draw_input_field('customers_firstname', $cInfo->customers_firstname, 'maxlength="32"') . ' ' . ENTRY_FIRST_NAME_ERROR;

   } else {

     echo $cInfo->customers_firstname . tep_draw_hidden_field('customers_firstname');

   }

 } else {

   echo tep_draw_input_field('customers_firstname', $cInfo->customers_firstname, 'maxlength="32"', true);

 }

?></td>

         </tr>

         <tr>

           <td class="main"><?php echo ENTRY_LAST_NAME; ?></td>

           <td class="main">

<?php

 if ($error == true) {

   if ($entry_lastname_error == true) {

     echo tep_draw_input_field('customers_lastname', $cInfo->customers_lastname, 'maxlength="32"') . ' ' . ENTRY_LAST_NAME_ERROR;

   } else {

     echo $cInfo->customers_lastname . tep_draw_hidden_field('customers_lastname');

   }

 } else {

   echo tep_draw_input_field('customers_lastname', $cInfo->customers_lastname, 'maxlength="32"', true);

 }

?></td>

         </tr>

<?php

   if (ACCOUNT_DOB == 'true') {

?>

         <tr>

           <td class="main"><?php echo ENTRY_DATE_OF_BIRTH; ?></td>

           <td class="main">

 

<?php

   if ($error == true) {

     if ($entry_date_of_birth_error == true) {

       echo tep_draw_input_field('customers_dob', tep_date_short($cInfo->customers_dob), 'maxlength="10"') . ' ' . ENTRY_DATE_OF_BIRTH_ERROR;

     } else {

       echo $cInfo->customers_dob . tep_draw_hidden_field('customers_dob');

     }

   } else {

     echo tep_draw_input_field('customers_dob', tep_date_short($cInfo->customers_dob), 'maxlength="10"', true);

   }

?></td>

         </tr>

<?php

   }

?>

         <tr>

           <td class="main"><?php echo ENTRY_EMAIL_ADDRESS; ?></td>

           <td class="main">

<?php

 if ($error == true) {

   if ($entry_email_address_error == true) {

     echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength="96"') . ' ' . ENTRY_EMAIL_ADDRESS_ERROR;

   } elseif ($entry_email_address_check_error == true) {

     echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength="96"') . ' ' . ENTRY_EMAIL_ADDRESS_CHECK_ERROR;

   } elseif ($entry_email_address_exists == true) {

     echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength="96"') . ' ' . ENTRY_EMAIL_ADDRESS_ERROR_EXISTS;

   } else {

     echo $customers_email_address . tep_draw_hidden_field('customers_email_address');

   }

 } else {

   echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength="96"', true);

 }

?></td>

         </tr>

       </table></td>

     </tr>

<?php

   if (ACCOUNT_COMPANY == 'true') {

?>

     <tr>

       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

     </tr>

     <tr>

       <td class="formAreaTitle"><?php echo CATEGORY_COMPANY; ?></td>

     </tr>

     <tr>

       <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">

         <tr>

           <td class="main"><?php echo ENTRY_COMPANY; ?></td>

           <td class="main">

<?php

   if ($error == true) {

     if ($entry_company_error == true) {

       echo tep_draw_input_field('entry_company', $cInfo->entry_company, 'maxlength="32"') . ' ' . ENTRY_COMPANY_ERROR;

     } else {

       echo $cInfo->entry_company . tep_draw_hidden_field('entry_company');

     }

   } else {

     echo tep_draw_input_field('entry_company', $cInfo->entry_company, 'maxlength="32"');

   }

?></td>

         </tr>

       </table></td>

     </tr>

<?php

   }

?>

     <tr>

       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

     </tr>

     <tr>

       <td class="formAreaTitle"><?php echo CATEGORY_ADDRESS; ?></td>

     </tr>

     <tr>

       <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">

         <tr>

           <td class="main"><?php echo ENTRY_STREET_ADDRESS; ?></td>

           <td class="main">

<?php

 if ($error == true) {

   if ($entry_street_address_error == true) {

     echo tep_draw_input_field('entry_street_address', $cInfo->entry_street_address, 'maxlength="64"') . ' ' . ENTRY_STREET_ADDRESS_ERROR;

   } else {

     echo $cInfo->entry_street_address . tep_draw_hidden_field('entry_street_address');

   }

 } else {

   echo tep_draw_input_field('entry_street_address', $cInfo->entry_street_address, 'maxlength="64"', true);

 }

?></td>

         </tr>

<?php

   if (ACCOUNT_SUBURB == 'true') {

?>

         <tr>

           <td class="main"><?php echo ENTRY_SUBURB; ?></td>

           <td class="main">

<?php

   if ($error == true) {

     if ($entry_suburb_error == true) {

       echo tep_draw_input_field('suburb', $cInfo->entry_suburb, 'maxlength="32"') . ' ' . ENTRY_SUBURB_ERROR;

     } else {

       echo $cInfo->entry_suburb . tep_draw_hidden_field('entry_suburb');

     }

   } else {

     echo tep_draw_input_field('entry_suburb', $cInfo->entry_suburb, 'maxlength="32"');

   }

?></td>

         </tr>

<?php

   }

?>

         <tr>

           <td class="main"><?php echo ENTRY_POST_CODE; ?></td>

           <td class="main">

<?php

 if ($error == true) {

   if ($entry_post_code_error == true) {

     echo tep_draw_input_field('entry_postcode', $cInfo->entry_postcode, 'maxlength="8"') . ' ' . ENTRY_POST_CODE_ERROR;

   } else {

     echo $cInfo->entry_postcode . tep_draw_hidden_field('entry_postcode');

   }

 } else {

   echo tep_draw_input_field('entry_postcode', $cInfo->entry_postcode, 'maxlength="8"', true);

 }

?></td>

         </tr>

         <tr>

           <td class="main"><?php echo ENTRY_CITY; ?></td>

           <td class="main">

<?php

 if ($error == true) {

   if ($entry_city_error == true) {

     echo tep_draw_input_field('entry_city', $cInfo->entry_city, 'maxlength="32"') . ' ' . ENTRY_CITY_ERROR;

   } else {

     echo $cInfo->entry_city . tep_draw_hidden_field('entry_city');

   }

 } else {

   echo tep_draw_input_field('entry_city', $cInfo->entry_city, 'maxlength="32"', true);

 }

?></td>

         </tr>

<?php

   if (ACCOUNT_STATE == 'true') {

?>

         <tr>

           <td class="main"><?php echo ENTRY_STATE; ?></td>

           <td class="main">

<?php

   $entry_state = tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state);

   if ($error == true) {

     if ($entry_state_error == true) {

       if ($entry_state_has_zones == true) {

         $zones_array = array();

         $zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . tep_db_input($cInfo->entry_country_id) . "' order by zone_name");

         while ($zones_values = tep_db_fetch_array($zones_query)) {

           $zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);

         }

         echo tep_draw_pull_down_menu('entry_state', $zones_array) . ' ' . ENTRY_STATE_ERROR;

       } else {

         echo tep_draw_input_field('entry_state', tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state)) . ' ' . ENTRY_STATE_ERROR;

       }

     } else {

       echo $entry_state . tep_draw_hidden_field('entry_zone_id') . tep_draw_hidden_field('entry_state');

     }

   } else {

     echo tep_draw_input_field('entry_state', tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state));

   }

 

?></td>

        </tr>

<?php

   }

?>

         <tr>

           <td class="main"><?php echo ENTRY_COUNTRY; ?></td>

           <td class="main">

<?php

 if ($error == true) {

   if ($entry_country_error == true) {

     echo tep_draw_pull_down_menu('entry_country_id', tep_get_countries(), $cInfo->entry_country_id) . ' ' . ENTRY_COUNTRY_ERROR;

   } else {

     echo tep_get_country_name($cInfo->entry_country_id) . tep_draw_hidden_field('entry_country_id');

   }

 } else {

   echo tep_draw_pull_down_menu('entry_country_id', tep_get_countries(), $cInfo->entry_country_id);

 }

?></td>

         </tr>

       </table></td>

     </tr>

     <tr>

       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

     </tr>

     <tr>

       <td class="formAreaTitle"><?php echo CATEGORY_CONTACT; ?></td>

     </tr>

     <tr>

       <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">

         <tr>

           <td class="main"><?php echo ENTRY_TELEPHONE_NUMBER; ?></td>

           <td class="main">

<?php

 if ($error == true) {

   if ($entry_telephone_error == true) {

     echo tep_draw_input_field('customers_telephone', $cInfo->customers_telephone, 'maxlength="32"') . ' ' . ENTRY_TELEPHONE_NUMBER_ERROR;

   } else {

     echo $cInfo->customers_telephone . tep_draw_hidden_field('customers_telephone');

   }

 } else {

   echo tep_draw_input_field('customers_telephone', $cInfo->customers_telephone, 'maxlength="32"', true);

 }

?></td>

         </tr>

         <tr>

           <td class="main"><?php echo ENTRY_FAX_NUMBER; ?></td>

           <td class="main">

<?php

 if ($processed == true) {

   echo $cInfo->customers_fax . tep_draw_hidden_field('customers_fax');

 } else {

   echo tep_draw_input_field('customers_fax', $cInfo->customers_fax, 'maxlength="32"');

 }

?></td>

         </tr>

       </table></td>

     </tr>

     <tr>

       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

     </tr>

     <tr>

       <td class="formAreaTitle"><?php echo CATEGORY_OPTIONS; ?></td>

     </tr>

     <tr>

       <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">

         <tr>

           <td class="main"><?php echo ENTRY_NEWSLETTER; ?></td>

           <td class="main">

<?php

 if ($processed == true) {

   if ($cInfo->customers_newsletter == '1') {

     echo ENTRY_NEWSLETTER_YES;

   } else {

     echo ENTRY_NEWSLETTER_NO;

   }

   echo tep_draw_hidden_field('customers_newsletter');

 } else {

   echo tep_draw_pull_down_menu('customers_newsletter', $newsletter_array, (($cInfo->customers_newsletter == '1') ? '1' : '0'));

 }

?></td>

         </tr>

   <tr>

 <td class="main"><?php echo ENTRY_CUSTOMERS_GROUP_NAME; ?></td>

 <td class="main"><?php echo tep_draw_input_field('customers_group_name', $cInfo->customers_group_name, 'maxlength="25"'); ?></td>

</tr>

<tr>

 <td class="main"><?php

 $index = 0;

 echo ("Existing Groups: ");

 while ($existing_customers =  tep_db_fetch_array($existing_customers_query)) {

   echo ($existing_customers['customers_group_name']);

   echo (", ");

   ++$index;

   if ($index%10 == 0) {

   echo (" ");

   }

 }?>

 </td>

</tr>

       </table></td>

     </tr>

     <tr>

       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

     </tr>

     <tr>

       <td align="right" class="main"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('action'))) .'">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>

     </tr></form>

<?php

 } else {

?>

     <tr>

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

         <tr><?php echo tep_draw_form('search', FILENAME_CUSTOMERS, '', 'get'); ?>

           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

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

           <td class="smallText" align="right"><?php echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search'); ?></td>

         </form></tr>

       </table></td>

     </tr>

     <tr>

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

         <tr>

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

             <tr class="dataTableHeadingRow">

               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LASTNAME; ?></td>

               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_FIRSTNAME; ?></td>

               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACCOUNT_CREATED; ?></td>

               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>

             </tr>

<?php

   $search = '';

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

     $keywords = tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['search']));

     $search = "where c.customers_lastname like '%" . $keywords . "%' or c.customers_firstname like '%" . $keywords . "%' or c.customers_email_address like '%" . $keywords . "%'";

   }

   $customers_query_raw = "select c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, a.entry_country_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id " . $search . " order by c.customers_lastname, c.customers_firstname";

   $customers_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $customers_query_raw, $customers_query_numrows);

   $customers_query = tep_db_query($customers_query_raw);

   while ($customers = tep_db_fetch_array($customers_query)) {

     $info_query = tep_db_query("select customers_info_date_account_created as date_account_created, customers_info_date_account_last_modified as date_account_last_modified, customers_info_date_of_last_logon as date_last_logon, customers_info_number_of_logons as number_of_logons from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . $customers['customers_id'] . "'");

     $info = tep_db_fetch_array($info_query);

 

     if ((!isset($HTTP_GET_VARS['cID']) || (isset($HTTP_GET_VARS['cID']) && ($HTTP_GET_VARS['cID'] == $customers['customers_id']))) && !isset($cInfo)) {

       $country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$customers['entry_country_id'] . "'");

       $country = tep_db_fetch_array($country_query);

 

       $reviews_query = tep_db_query("select count(*) as number_of_reviews from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers['customers_id'] . "'");

       $reviews = tep_db_fetch_array($reviews_query);

 

       $customer_info = array_merge($country, $info, $reviews);

 

       $cInfo_array = array_merge($customers, $customer_info);

       $cInfo = new objectInfo($cInfo_array);

     }

 

     if (isset($cInfo) && is_object($cInfo) && ($customers['customers_id'] == $cInfo->customers_id)) {

       echo '          <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=edit') . '\'">' . "\n";

     } else {

       echo '          <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID')) . 'cID=' . $customers['customers_id']) . '\'">' . "\n";

     }

?>

               <td class="dataTableContent"><?php echo $customers['customers_lastname']; ?></td>

               <td class="dataTableContent"><?php echo $customers['customers_firstname']; ?></td>

               <td class="dataTableContent" align="right"><?php echo tep_date_short($info['date_account_created']); ?></td>

               <td class="dataTableContent" align="right"><?php if (isset($cInfo) && is_object($cInfo) && ($customers['customers_id'] == $cInfo->customers_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID')) . 'cID=' . $customers['customers_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>

             </tr>

<?php

   }

?>

             <tr>

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

                 <tr>

                   <td class="smallText" valign="top"><?php echo $customers_split->display_count($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_CUSTOMERS); ?></td>

                   <td class="smallText" align="right"><?php echo $customers_split->display_links($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y', 'cID'))); ?></td>

                 </tr>

<?php

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

?>

                 <tr>

                   <td align="right" colspan="2"><?php echo '<a href="

Link to comment
Share on other sites

Here is my code:

 

<?php

/*

 $Id: customers.php,v 1.82 2003/06/30 13:54:14 dgw_ Exp $

 

 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com

 

 Copyright (c) 2003 osCommerce

 

 Released under the GNU General Public License

*/

 

 require('includes/application_top.php');

 

 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 

 $error = false;

 $processed = false;

 

 if (tep_not_null($action)) {

   switch ($action) {

     case 'update':

       $customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);

       $customers_firstname = tep_db_prepare_input($HTTP_POST_VARS['customers_firstname']);

       $customers_lastname = tep_db_prepare_input($HTTP_POST_VARS['customers_lastname']);

       $customers_email_address = tep_db_prepare_input($HTTP_POST_VARS['customers_email_address']);

       $customers_telephone = tep_db_prepare_input($HTTP_POST_VARS['customers_telephone']);

       $customers_fax = tep_db_prepare_input($HTTP_POST_VARS['customers_fax']);

       $customers_newsletter = tep_db_prepare_input($HTTP_POST_VARS['customers_newsletter']);

 $multiple_groups_query = tep_db_query("select distinct customers_group_id from " . TABLE_PRODUCTS_GROUPS . " ");

while ($group_ids = tep_db_fetch_array($multiple_groups_query)) {

 $multiple_customers_query = tep_db_query("select distinct customers_group_id from " . TABLE_CUSTOMERS . " where customers_group_id = " . $group_ids['customers_group_id'] . " ");

 if (!($multiple_groups = tep_db_fetch_array($multiple_customers_query))) {

   tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $group_ids['customers_group_id'] . "'");

 }

}

 

$customers_group_name = tep_db_prepare_input($HTTP_POST_VARS['customers_group_name']);

$counter = 0;

$assigned = 0;

 

$customers_group_name_query = tep_db_query("select distinct customers_group_name, customers_group_id from " . TABLE_CUSTOMERS . " order by customers_group_id");

 

while ($group_name_check = tep_db_fetch_array($customers_group_name_query)) {

$counter = $group_name_check['customers_group_id'];

 

 if ($group_name_check['customers_group_name'] == $customers_group_name) {

   $customers_group_id = $group_name_check['customers_group_id'];

$assigned = 1;

   break;

 }

   

 ++$counter;

}

 

if ($assigned == 0) {

 $customers_group_id = $counter;

}

 

       $customers_gender = tep_db_prepare_input($HTTP_POST_VARS['customers_gender']);

       $customers_dob = tep_db_prepare_input($HTTP_POST_VARS['customers_dob']);

 

       $default_address_id = tep_db_prepare_input($HTTP_POST_VARS['default_address_id']);

       $entry_street_address = tep_db_prepare_input($HTTP_POST_VARS['entry_street_address']);

       $entry_suburb = tep_db_prepare_input($HTTP_POST_VARS['entry_suburb']);

       $entry_postcode = tep_db_prepare_input($HTTP_POST_VARS['entry_postcode']);

       $entry_city = tep_db_prepare_input($HTTP_POST_VARS['entry_city']);

       $entry_country_id = tep_db_prepare_input($HTTP_POST_VARS['entry_country_id']);

 

       $entry_company = tep_db_prepare_input($HTTP_POST_VARS['entry_company']);

       $entry_state = tep_db_prepare_input($HTTP_POST_VARS['entry_state']);

       if (isset($HTTP_POST_VARS['entry_zone_id'])) $entry_zone_id = tep_db_prepare_input($HTTP_POST_VARS['entry_zone_id']);

 

       if (strlen($customers_firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {

         $error = true;

         $entry_firstname_error = true;

       } else {

         $entry_firstname_error = false;

       }

 

       if (strlen($customers_lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {

         $error = true;

         $entry_lastname_error = true;

       } else {

         $entry_lastname_error = false;

       }

 

       if (ACCOUNT_DOB == 'true') {

         if (checkdate(substr(tep_date_raw($customers_dob), 4, 2), substr(tep_date_raw($customers_dob), 6, 2), substr(tep_date_raw($customers_dob), 0, 4))) {

           $entry_date_of_birth_error = false;

         } else {

           $error = true;

           $entry_date_of_birth_error = true;

         }

       }

 

       if (strlen($customers_email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {

         $error = true;

         $entry_email_address_error = true;

       } else {

         $entry_email_address_error = false;

       }

 

       if (!tep_validate_email($customers_email_address)) {

         $error = true;

         $entry_email_address_check_error = true;

       } else {

         $entry_email_address_check_error = false;

       }

 

       if (strlen($entry_street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {

         $error = true;

         $entry_street_address_error = true;

       } else {

         $entry_street_address_error = false;

       }

 

       if (strlen($entry_postcode) < ENTRY_POSTCODE_MIN_LENGTH) {

         $error = true;

         $entry_post_code_error = true;

       } else {

         $entry_post_code_error = false;

       }

 

       if (strlen($entry_city) < ENTRY_CITY_MIN_LENGTH) {

         $error = true;

         $entry_city_error = true;

       } else {

         $entry_city_error = false;

       }

 

       if ($entry_country_id == false) {

         $error = true;

         $entry_country_error = true;

       } else {

         $entry_country_error = false;

       }

 

       if (ACCOUNT_STATE == 'true') {

         if ($entry_country_error == true) {

           $entry_state_error = true;

         } else {

           $zone_id = 0;

           $entry_state_error = false;

           $check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . (int)$entry_country_id . "'");

           $check_value = tep_db_fetch_array($check_query);

           $entry_state_has_zones = ($check_value['total'] > 0);

           if ($entry_state_has_zones == true) {

             $zone_query = tep_db_query("select zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$entry_country_id . "' and zone_name = '" . tep_db_input($entry_state) . "'");

             if (tep_db_num_rows($zone_query) == 1) {

               $zone_values = tep_db_fetch_array($zone_query);

               $entry_zone_id = $zone_values['zone_id'];

             } else {

               $error = true;

               $entry_state_error = true;

             }

           } else {

             if ($entry_state == false) {

               $error = true;

               $entry_state_error = true;

             }

           }

        }

     }

 

     if (strlen($customers_telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {

       $error = true;

       $entry_telephone_error = true;

     } else {

       $entry_telephone_error = false;

     }

 

     $check_email = tep_db_query("select customers_email_address from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($customers_email_address) . "' and customers_id != '" . (int)$customers_id . "'");

     if (tep_db_num_rows($check_email)) {

       $error = true;

       $entry_email_address_exists = true;

     } else {

       $entry_email_address_exists = false;

     }

 

     if ($error == false) {

 

       $sql_data_array = array('customers_firstname' => $customers_firstname,

                               'customers_lastname' => $customers_lastname,

                               'customers_email_address' => $customers_email_address,

                               'customers_telephone' => $customers_telephone,

                               'customers_fax' => $customers_fax,

                               'customers_newsletter' => $customers_newsletter,

       'customers_group_id' => $customers_group_id,

       'customers_group_name' => $customers_group_name);

 

       if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $customers_gender;

       if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($customers_dob);

 

       tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "'");

 

       tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int)$customers_id . "'");

 

       if ($entry_zone_id > 0) $entry_state = '';

 

       $sql_data_array = array('entry_firstname' => $customers_firstname,

                               'entry_lastname' => $customers_lastname,

                               'entry_street_address' => $entry_street_address,

                               'entry_postcode' => $entry_postcode,

                               'entry_city' => $entry_city,

                               'entry_country_id' => $entry_country_id);

 

       if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $entry_company;

       if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $entry_suburb;

 

       if (ACCOUNT_STATE == 'true') {

         if ($entry_zone_id > 0) {

           $sql_data_array['entry_zone_id'] = $entry_zone_id;

           $sql_data_array['entry_state'] = '';

         } else {

           $sql_data_array['entry_zone_id'] = '0';

           $sql_data_array['entry_state'] = $entry_state;

         }

       }

 

       tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$default_address_id . "'");

 

       tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $customers_id));

 

       } else if ($error == true) {

         $cInfo = new objectInfo($HTTP_POST_VARS);

         $processed = true;

       }

 

       break;

     case 'deleteconfirm':

       $customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);

 

       if (isset($HTTP_POST_VARS['delete_reviews']) && ($HTTP_POST_VARS['delete_reviews'] == 'on')) {

         $reviews_query = tep_db_query("select reviews_id from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers_id . "'");

         while ($reviews = tep_db_fetch_array($reviews_query)) {

           tep_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$reviews['reviews_id'] . "'");

         }

 

         tep_db_query("delete from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers_id . "'");

       } else {

         tep_db_query("update " . TABLE_REVIEWS . " set customers_id = null where customers_id = '" . (int)$customers_id . "'");

       }

 $multiple_groups_query = tep_db_query("select distinct customers_group_id from " . TABLE_PRODUCTS_GROUPS . " ");

while ($group_ids = tep_db_fetch_array($multiple_groups_query)) {

 $multiple_customers_query = tep_db_query("select distinct customers_group_id from " . TABLE_CUSTOMERS . " where customers_group_id = " . $group_ids['customers_group_id'] . " ");

 if (!($multiple_groups = tep_db_fetch_array($multiple_customers_query))) {

   tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $group_ids['customers_group_id'] . "'");

 }

}

 

       tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "'");

       tep_db_query("delete from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");

       tep_db_query("delete from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customers_id . "'");

       tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customers_id . "'");

       tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customers_id . "'");

       tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where customer_id = '" . (int)$customers_id . "'");

 

       tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action'))));

       break;

     default:

       $customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_group_name, c.customers_default_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . $HTTP_GET_VARS['cID'] . "'");

 $existing_customers_query = tep_db_query("select distinct customers_group_name from " . TABLE_CUSTOMERS . " order by customers_group_id ");

       $customers = tep_db_fetch_array($customers_query);

       $cInfo = new objectInfo($customers);

   }

 }

?>

<!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>

<?php

 if ($action == 'edit' || $action == 'update') {

?>

<script language="javascript"><!--

 

function check_form() {

 var error = 0;

 var error_message = "<?php echo JS_ERROR; ?>";

 

 var customers_firstname = document.customers.customers_firstname.value;

 var customers_lastname = document.customers.customers_lastname.value;

<?php if (ACCOUNT_COMPANY == 'true') echo 'var entry_company = document.customers.entry_company.value;' . "\n"; ?>

<?php if (ACCOUNT_DOB == 'true') echo 'var customers_dob = document.customers.customers_dob.value;' . "\n"; ?>

 var customers_email_address = document.customers.customers_email_address.value;

 var entry_street_address = document.customers.entry_street_address.value;

 var entry_postcode = document.customers.entry_postcode.value;

 var entry_city = document.customers.entry_city.value;

 var customers_telephone = document.customers.customers_telephone.value;

 

<?php if (ACCOUNT_GENDER == 'true') { ?>

 if (document.customers.customers_gender[0].checked || document.customers.customers_gender[1].checked) {

 } else {

   error_message = error_message + "<?php echo JS_GENDER; ?>";

   error = 1;

 }

<?php } ?>

 

 if (customers_firstname == "" || customers_firstname.length < <?php echo ENTRY_FIRST_NAME_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_FIRST_NAME; ?>";

   error = 1;

 }

 

 if (customers_lastname == "" || customers_lastname.length < <?php echo ENTRY_LAST_NAME_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_LAST_NAME; ?>";

   error = 1;

 }

 

<?php if (ACCOUNT_DOB == 'true') { ?>

 if (customers_dob == "" || customers_dob.length < <?php echo ENTRY_DOB_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_DOB; ?>";

   error = 1;

 }

<?php } ?>

 

 if (customers_email_address == "" || customers_email_address.length < <?php echo ENTRY_EMAIL_ADDRESS_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_EMAIL_ADDRESS; ?>";

   error = 1;

 }

 

 if (entry_street_address == "" || entry_street_address.length < <?php echo ENTRY_STREET_ADDRESS_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_ADDRESS; ?>";

   error = 1;

 }

 

 if (entry_postcode == "" || entry_postcode.length < <?php echo ENTRY_POSTCODE_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_POST_CODE; ?>";

   error = 1;

 }

 

 if (entry_city == "" || entry_city.length < <?php echo ENTRY_CITY_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_CITY; ?>";

   error = 1;

 }

 

<?php

 if (ACCOUNT_STATE == 'true') {

?>

 if (document.customers.elements['entry_state'].type != "hidden") {

   if (document.customers.entry_state.value == '' || document.customers.entry_state.value.length < <?php echo ENTRY_STATE_MIN_LENGTH; ?> ) {

      error_message = error_message + "<?php echo JS_STATE; ?>";

      error = 1;

   }

 }

<?php

 }

?>

 

 if (document.customers.elements['entry_country_id'].type != "hidden") {

   if (document.customers.entry_country_id.value == 0) {

     error_message = error_message + "<?php echo JS_COUNTRY; ?>";

     error = 1;

   }

 }

 

 if (customers_telephone == "" || customers_telephone.length < <?php echo ENTRY_TELEPHONE_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_TELEPHONE; ?>";

   error = 1;

 }

 

 if (error == 1) {

   alert(error_message);

   return false;

 } else {

   return true;

 }

}

//--></script>

<?php

 }

?>

</head>

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

<!-- 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">

<?php

 if ($action == 'edit' || $action == 'update') {

   $newsletter_array = array(array('id' => '1', 'text' => ENTRY_NEWSLETTER_YES),

                             array('id' => '0', 'text' => ENTRY_NEWSLETTER_NO));

?>

     <tr>

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

         <tr>

           <td class="pageHeading"><?php echo HEADING_TITLE; ?></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 echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

     </tr>

     <tr><?php echo tep_draw_form('customers', FILENAME_CUSTOMERS, tep_get_all_get_params(array('action')) . 'action=update', 'post', 'onSubmit="return check_form();"') . tep_draw_hidden_field('default_address_id', $cInfo->customers_default_address_id); ?>

       <td class="formAreaTitle"><?php echo CATEGORY_PERSONAL; ?></td>

     </tr>

     <tr>

       <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">

<?php

   if (ACCOUNT_GENDER == 'true') {

?>

         <tr>

           <td class="main"><?php echo ENTRY_GENDER; ?></td>

           <td class="main">

<?php

   if ($error == true) {

     if ($entry_gender_error == true) {

       echo tep_draw_radio_field('customers_gender', 'm', false, $cInfo->customers_gender) . '  ' . MALE . '  ' . tep_draw_radio_field('customers_gender', 'f', false, $cInfo->customers_gender) . '  ' . FEMALE . ' ' . ENTRY_GENDER_ERROR;

     } else {

       echo ($cInfo->customers_gender == 'm') ? MALE : FEMALE;

       echo tep_draw_hidden_field('customers_gender');

     }

   } else {

     echo tep_draw_radio_field('customers_gender', 'm', false, $cInfo->customers_gender) . '  ' . MALE . '  ' . tep_draw_radio_field('customers_gender', 'f', false, $cInfo->customers_gender) . '  ' . FEMALE;

   }

?></td>

         </tr>

<?php

   }

?>

         <tr>

           <td class="main"><?php echo ENTRY_FIRST_NAME; ?></td>

           <td class="main">

<?php

 if ($error == true) {

   if ($entry_firstname_error == true) {

     echo tep_draw_input_field('customers_firstname', $cInfo->customers_firstname, 'maxlength="32"') . ' ' . ENTRY_FIRST_NAME_ERROR;

   } else {

     echo $cInfo->customers_firstname . tep_draw_hidden_field('customers_firstname');

   }

 } else {

   echo tep_draw_input_field('customers_firstname', $cInfo->customers_firstname, 'maxlength="32"', true);

 }

?></td>

         </tr>

         <tr>

           <td class="main"><?php echo ENTRY_LAST_NAME; ?></td>

           <td class="main">

<?php

 if ($error == true) {

   if ($entry_lastname_error == true) {

     echo tep_draw_input_field('customers_lastname', $cInfo->customers_lastname, 'maxlength="32"') . ' ' . ENTRY_LAST_NAME_ERROR;

   } else {

     echo $cInfo->customers_lastname . tep_draw_hidden_field('customers_lastname');

   }

 } else {

   echo tep_draw_input_field('customers_lastname', $cInfo->customers_lastname, 'maxlength="32"', true);

 }

?></td>

         </tr>

<?php

   if (ACCOUNT_DOB == 'true') {

?>

         <tr>

           <td class="main"><?php echo ENTRY_DATE_OF_BIRTH; ?></td>

           <td class="main">

 

<?php

   if ($error == true) {

     if ($entry_date_of_birth_error == true) {

       echo tep_draw_input_field('customers_dob', tep_date_short($cInfo->customers_dob), 'maxlength="10"') . ' ' . ENTRY_DATE_OF_BIRTH_ERROR;

     } else {

       echo $cInfo->customers_dob . tep_draw_hidden_field('customers_dob');

     }

   } else {

     echo tep_draw_input_field('customers_dob', tep_date_short($cInfo->customers_dob), 'maxlength="10"', true);

   }

?></td>

         </tr>

<?php

   }

?>

         <tr>

           <td class="main"><?php echo ENTRY_EMAIL_ADDRESS; ?></td>

           <td class="main">

<?php

 if ($error == true) {

   if ($entry_email_address_error == true) {

     echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength="96"') . ' ' . ENTRY_EMAIL_ADDRESS_ERROR;

   } elseif ($entry_email_address_check_error == true) {

     echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength="96"') . ' ' . ENTRY_EMAIL_ADDRESS_CHECK_ERROR;

   } elseif ($entry_email_address_exists == true) {

     echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength="96"') . ' ' . ENTRY_EMAIL_ADDRESS_ERROR_EXISTS;

   } else {

     echo $customers_email_address . tep_draw_hidden_field('customers_email_address');

   }

 } else {

   echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength="96"', true);

 }

?></td>

         </tr>

       </table></td>

     </tr>

<?php

   if (ACCOUNT_COMPANY == 'true') {

?>

     <tr>

       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

     </tr>

     <tr>

       <td class="formAreaTitle"><?php echo CATEGORY_COMPANY; ?></td>

     </tr>

     <tr>

       <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">

         <tr>

           <td class="main"><?php echo ENTRY_COMPANY; ?></td>

           <td class="main">

<?php

   if ($error == true) {

     if ($entry_company_error == true) {

       echo tep_draw_input_field('entry_company', $cInfo->entry_company, 'maxlength="32"') . ' ' . ENTRY_COMPANY_ERROR;

     } else {

       echo $cInfo->entry_company . tep_draw_hidden_field('entry_company');

     }

   } else {

     echo tep_draw_input_field('entry_company', $cInfo->entry_company, 'maxlength="32"');

   }

?></td>

         </tr>

       </table></td>

     </tr>

<?php

   }

?>

     <tr>

       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

     </tr>

     <tr>

       <td class="formAreaTitle"><?php echo CATEGORY_ADDRESS; ?></td>

     </tr>

     <tr>

       <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">

         <tr>

           <td class="main"><?php echo ENTRY_STREET_ADDRESS; ?></td>

           <td class="main">

<?php

 if ($error == true) {

   if ($entry_street_address_error == true) {

     echo tep_draw_input_field('entry_street_address', $cInfo->entry_street_address, 'maxlength="64"') . ' ' . ENTRY_STREET_ADDRESS_ERROR;

   } else {

     echo $cInfo->entry_street_address . tep_draw_hidden_field('entry_street_address');

   }

 } else {

   echo tep_draw_input_field('entry_street_address', $cInfo->entry_street_address, 'maxlength="64"', true);

 }

?></td>

         </tr>

<?php

   if (ACCOUNT_SUBURB == 'true') {

?>

         <tr>

           <td class="main"><?php echo ENTRY_SUBURB; ?></td>

           <td class="main">

<?php

   if ($error == true) {

     if ($entry_suburb_error == true) {

       echo tep_draw_input_field('suburb', $cInfo->entry_suburb, 'maxlength="32"') . ' ' . ENTRY_SUBURB_ERROR;

     } else {

       echo $cInfo->entry_suburb . tep_draw_hidden_field('entry_suburb');

     }

   } else {

     echo tep_draw_input_field('entry_suburb', $cInfo->entry_suburb, 'maxlength="32"');

   }

?></td>

         </tr>

<?php

   }

?>

         <tr>

           <td class="main"><?php echo ENTRY_POST_CODE; ?></td>

           <td class="main">

<?php

 if ($error == true) {

   if ($entry_post_code_error == true) {

     echo tep_draw_input_field('entry_postcode', $cInfo->entry_postcode, 'maxlength="8"') . ' ' . ENTRY_POST_CODE_ERROR;

   } else {

     echo $cInfo->entry_postcode . tep_draw_hidden_field('entry_postcode');

   }

 } else {

   echo tep_draw_input_field('entry_postcode', $cInfo->entry_postcode, 'maxlength="8"', true);

 }

?></td>

         </tr>

         <tr>

           <td class="main"><?php echo ENTRY_CITY; ?></td>

           <td class="main">

<?php

 if ($error == true) {

   if ($entry_city_error == true) {

     echo tep_draw_input_field('entry_city', $cInfo->entry_city, 'maxlength="32"') . ' ' . ENTRY_CITY_ERROR;

   } else {

     echo $cInfo->entry_city . tep_draw_hidden_field('entry_city');

   }

 } else {

   echo tep_draw_input_field('entry_city', $cInfo->entry_city, 'maxlength="32"', true);

 }

?></td>

         </tr>

<?php

   if (ACCOUNT_STATE == 'true') {

?>

         <tr>

           <td class="main"><?php echo ENTRY_STATE; ?></td>

           <td class="main">

<?php

   $entry_state = tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state);

   if ($error == true) {

     if ($entry_state_error == true) {

       if ($entry_state_has_zones == true) {

         $zones_array = array();

         $zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . tep_db_input($cInfo->entry_country_id) . "' order by zone_name");

         while ($zones_values = tep_db_fetch_array($zones_query)) {

           $zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);

         }

         echo tep_draw_pull_down_menu('entry_state', $zones_array) . ' ' . ENTRY_STATE_ERROR;

       } else {

         echo tep_draw_input_field('entry_state', tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state)) . ' ' . ENTRY_STATE_ERROR;

       }

     } else {

       echo $entry_state . tep_draw_hidden_field('entry_zone_id') . tep_draw_hidden_field('entry_state');

     }

   } else {

     echo tep_draw_input_field('entry_state', tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state));

   }

 

?></td>

        </tr>

<?php

   }

?>

         <tr>

           <td class="main"><?php echo ENTRY_COUNTRY; ?></td>

           <td class="main">

<?php

 if ($error == true) {

   if ($entry_country_error == true) {

     echo tep_draw_pull_down_menu('entry_country_id', tep_get_countries(), $cInfo->entry_country_id) . ' ' . ENTRY_COUNTRY_ERROR;

   } else {

     echo tep_get_country_name($cInfo->entry_country_id) . tep_draw_hidden_field('entry_country_id');

   }

 } else {

   echo tep_draw_pull_down_menu('entry_country_id', tep_get_countries(), $cInfo->entry_country_id);

 }

?></td>

         </tr>

       </table></td>

     </tr>

     <tr>

       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

     </tr>

     <tr>

       <td class="formAreaTitle"><?php echo CATEGORY_CONTACT; ?></td>

     </tr>

     <tr>

       <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">

         <tr>

           <td class="main"><?php echo ENTRY_TELEPHONE_NUMBER; ?></td>

           <td class="main">

<?php

 if ($error == true) {

   if ($entry_telephone_error == true) {

     echo tep_draw_input_field('customers_telephone', $cInfo->customers_telephone, 'maxlength="32"') . ' ' . ENTRY_TELEPHONE_NUMBER_ERROR;

   } else {

     echo $cInfo->customers_telephone . tep_draw_hidden_field('customers_telephone');

   }

 } else {

   echo tep_draw_input_field('customers_telephone', $cInfo->customers_telephone, 'maxlength="32"', true);

 }

?></td>

         </tr>

         <tr>

           <td class="main"><?php echo ENTRY_FAX_NUMBER; ?></td>

           <td class="main">

<?php

 if ($processed == true) {

   echo $cInfo->customers_fax . tep_draw_hidden_field('customers_fax');

 } else {

   echo tep_draw_input_field('customers_fax', $cInfo->customers_fax, 'maxlength="32"');

 }

?></td>

         </tr>

       </table></td>

     </tr>

     <tr>

       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

     </tr>

     <tr>

       <td class="formAreaTitle"><?php echo CATEGORY_OPTIONS; ?></td>

     </tr>

     <tr>

       <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">

         <tr>

           <td class="main"><?php echo ENTRY_NEWSLETTER; ?></td>

           <td class="main">

<?php

 if ($processed == true) {

   if ($cInfo->customers_newsletter == '1') {

     echo ENTRY_NEWSLETTER_YES;

   } else {

     echo ENTRY_NEWSLETTER_NO;

   }

   echo tep_draw_hidden_field('customers_newsletter');

 } else {

   echo tep_draw_pull_down_menu('customers_newsletter', $newsletter_array, (($cInfo->customers_newsletter == '1') ? '1' : '0'));

 }

?></td>

         </tr>

   <tr>

 <td class="main"><?php echo ENTRY_CUSTOMERS_GROUP_NAME; ?></td>

 <td class="main"><?php echo tep_draw_input_field('customers_group_name', $cInfo->customers_group_name, 'maxlength="25"'); ?></td>

</tr>

<tr>

 <td class="main"><?php

 $index = 0;

 echo ("Existing Groups: ");

 while ($existing_customers =  tep_db_fetch_array($existing_customers_query)) {

   echo ($existing_customers['customers_group_name']);

   echo (", ");

   ++$index;

   if ($index%10 == 0) {

   echo (" ");

   }

 }?>

 </td>

</tr>

       </table></td>

     </tr>

     <tr>

       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

     </tr>

     <tr>

       <td align="right" class="main"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('action'))) .'">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>

     </tr></form>

<?php

 } else {

?>

     <tr>

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

         <tr><?php echo tep_draw_form('search', FILENAME_CUSTOMERS, '', 'get'); ?>

           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

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

           <td class="smallText" align="right"><?php echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search'); ?></td>

         </form></tr>

       </table></td>

     </tr>

     <tr>

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

         <tr>

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

             <tr class="dataTableHeadingRow">

               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LASTNAME; ?></td>

               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_FIRSTNAME; ?></td>

               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACCOUNT_CREATED; ?></td>

               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>

             </tr>

<?php

   $search = '';

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

     $keywords = tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['search']));

     $search = "where c.customers_lastname like '%" . $keywords . "%' or c.customers_firstname like '%" . $keywords . "%' or c.customers_email_address like '%" . $keywords . "%'";

   }

   $customers_query_raw = "select c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, a.entry_country_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id " . $search . " order by c.customers_lastname, c.customers_firstname";

   $customers_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $customers_query_raw, $customers_query_numrows);

   $customers_query = tep_db_query($customers_query_raw);

   while ($customers = tep_db_fetch_array($customers_query)) {

     $info_query = tep_db_query("select customers_info_date_account_created as date_account_created, customers_info_date_account_last_modified as date_account_last_modified, customers_info_date_of_last_logon as date_last_logon, customers_info_number_of_logons as number_of_logons from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . $customers['customers_id'] . "'");

     $info = tep_db_fetch_array($info_query);

 

     if ((!isset($HTTP_GET_VARS['cID']) || (isset($HTTP_GET_VARS['cID']) && ($HTTP_GET_VARS['cID'] == $customers['customers_id']))) && !isset($cInfo)) {

       $country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$customers['entry_country_id'] . "'");

       $country = tep_db_fetch_array($country_query);

 

       $reviews_query = tep_db_query("select count(*) as number_of_reviews from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers['customers_id'] . "'");

       $reviews = tep_db_fetch_array($reviews_query);

 

       $customer_info = array_merge($country, $info, $reviews);

 

       $cInfo_array = array_merge($customers, $customer_info);

       $cInfo = new objectInfo($cInfo_array);

     }

 

     if (isset($cInfo) && is_object($cInfo) && ($customers['customers_id'] == $cInfo->customers_id)) {

       echo '          <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=edit') . '\'">' . "\n";

     } else {

       echo '          <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID')) . 'cID=' . $customers['customers_id']) . '\'">' . "\n";

     }

?>

               <td class="dataTableContent"><?php echo $customers['customers_lastname']; ?></td>

               <td class="dataTableContent"><?php echo $customers['customers_firstname']; ?></td>

               <td class="dataTableContent" align="right"><?php echo tep_date_short($info['date_account_created']); ?></td>

               <td class="dataTableContent" align="right"><?php if (isset($cInfo) && is_object($cInfo) && ($customers['customers_id'] == $cInfo->customers_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID')) . 'cID=' . $customers['customers_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>

             </tr>

<?php

   }

?>

             <tr>

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

                 <tr>

                   <td class="smallText" valign="top"><?php echo $customers_split->display_count($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_CUSTOMERS); ?></td>

                   <td class="smallText" align="right"><?php echo $customers_split->display_links($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y', 'cID'))); ?></td>

                 </tr>

<?php

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

?>

                 <tr>

                   <td align="right" colspan="2"><?php echo '<a href="

Link to comment
Share on other sites

Which contribution(s) are you using?

 

There are a couple errors in the code:

 

1. Line 34: Should look something like this $some_variable = tep_db_query(...)

2. Line 248: Same thing

3. Also check all of your query strings, make sure that quotes are open/closed properly and that they somewhat make sense based on the tables you are using. It is hard for me to tell without knowing which contributions you are using.

Link to comment
Share on other sites

Most likely it is the Separate_Pricing_Per_Customer_v3.5 contribution that is causing the problem you are seeing. I am not familiar with that one. My two recommendations to you are to take a look at your customers.php file and look at each query. Make sure quotes are opened and closed right and that the tables being queryed exist as well as the fields in the tables. Make the corrections I referred to in my earlier post. And lastly, if all else fails try searching the contributions support forum. I am sure someone there probably can help you better then I. Sorry.

Link to comment
Share on other sites

The error message is saying it is having a problem with this line of code:

 

 

return mysql_fetch_array($db_query, MYSQL_ASSOC);

 

 

Do you see anything wrong with it. Or is their anything else it come be called.

 

 

Any ideas?

Link to comment
Share on other sites

See my previous posts. Even though the error is reporting it to come from the database.php file, it is actually being caused by what is in the $dbquery variable. Since the customers.php is passing the variable to the function the problem is originating in the customers.php file. You will have to look there for the solution. Check the query strings there to ensure that the quotes are right and look at my previous posts to fix the two known errors on the page.

Link to comment
Share on other sites

Should I be looking at my sql database or at the code.

 

Sorry to ask but Ive only been doing php for 3 days now.

 

If Im meant to be looking at my sql database where should I look?

 

basically once recoding the files Im now getting the following error:

 

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sac9829/sacotech-www/catalog/admin/includes/functions/database.php on line 99

 

Warning: reset(): Passed variable is not an array or object in /home/sac9829/sacotech-www/catalog/admin/includes/classes/object_info.php on line 17

 

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

 

 

Im working to the admin section of the customers

Link to comment
Share on other sites

You should be looking at the customers.php file. That is where the tep_mysql_fetch_array function is being called. You need to look at the code there and go through it and find each select statement and check to make sure it has the proper quotes and is referring to valid tables, fields. Also, you need to fix the two lines of code I referred to in my earlier post.

 

There are a couple errors in the code:

 

1. Line 34: Should look something like this $some_variable = tep_db_query(...)

2. Line 248: Same thing[\QUOTE]

 

You may want to search the contributions support forum for help with this particular contribution. I am not familiar with it, but it seems there is a problem with the code somewhere.

Link to comment
Share on other sites

Thanks for helping

 

I have msg the creater but waiting for him to get back to me because in his mod he says to add those to lines of code that you say are incorrect:

 

Add:

$multiple_groups_query = tep_db_query("select distinct customers_group_id from " . TABLE_PRODUCTS_GROUPS . " ");
while ($group_ids = tep_db_fetch_array($multiple_groups_query)) {
?$multiple_customers_query = tep_db_query("select distinct customers_group_id from " . TABLE_CUSTOMERS . " where customers_group_id = " . $group_ids['customers_group_id'] . " ");
?if (!($multiple_groups = tep_db_fetch_array($multiple_customers_query))) {
? [B] tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $group_ids['customers_group_id'] . "'");[/B] ?}
}

$customers_group_name = tep_db_prepare_input($HTTP_POST_VARS['customers_group_name']);
$counter = 0;
$assigned = 0;
?
$customers_group_name_query = tep_db_query("select distinct customers_group_name, customers_group_id from " . TABLE_CUSTOMERS . " order by customers_group_id");

while ($group_name_check = tep_db_fetch_array($customers_group_name_query)) {
$counter = $group_name_check['customers_group_id'];
?
?if ($group_name_check['customers_group_name'] == $customers_group_name) {
? ?$customers_group_id = $group_name_check['customers_group_id'];
$assigned = 1;
? ?break;
?}
? ?
?++$counter;
}

if ($assigned == 0) {
?$customers_group_id = $counter;
}

 

But I will see what he says!

Link to comment
Share on other sites

Sorry, but I steered you wrong previously. :o

 

The lines of code I said were wrong are actually okay.

 

You need to compare your code to the instructions for the seperate pricing contribution. Make sure there are no typos or anything. Also, did you make the appropriate changes to the database?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...