View Single Post
  #6  
Old 03-02-2004, 12:36 PM
 
mark_d mark_d is offline
 

Advanced Member
  
Join Date: Jun 2003
Posts: 39
 

Default a possible solutuion

Some had this posted a while back - SOMEHOW this import post was deleted - Humm??

anyway heres the code:

Code:
?php // check path to xcart/include/func.php file include "../estore/include/func.php"; # SALT & CODE for user password & credit card encryption # take it from your xcart/config.php file $CRYPT_SALT = 85; # any number ranging 1-255 $START_CHAR_CODE = 100; # 'd' letter // import from file $myfile = file("customer.txt"); // MySQL Server Info $sql_host ='SQL_server'; $sql_user ='username'; $sql_db ='database_name'; $sql_password ='password'; $customers_table = 'xcart_customers'; $maillist_table = 'xcart_maillist'; // create connection to MySQL server @mysql_pconnect($sql_host,$sql_user,$sql_password) or die("Couldn't make connection."); // select the database @mysql_select_db($sql_db) or die("Couldn't select $database database."); for ($index=0; $index < count($myfile); $index++) { $new_subs = split("\ ", chop($myfile[$index])); // import file structure can be different in your case // $email =$new_subs[0]; // $password =text_crypt($new_subs[1]); // $b_firstname =ucwords($new_subs[2]); // $b_lastname =ucwords($new_subs[3]); // $b_company =ucwords($new_subs[4]); // $b_addr =ucwords($new_subs[5]); // $b_addr2 =ucwords($new_subs[6]); // $b_city =ucwords($new_subs[7]); // $b_state =$new_subs[8]; // $b_zipcode =$new_subs[9]; // $b_phone =$new_subs[10]; // $s_name =ucwords($new_subs[11]); // $s_company =ucwords($new_subs[12]); // $s_addr =$new_subs[13]; // $s_addr2 =$new_subs[14]; // $s_city =ucwords($new_subs[15]); // $s_state =$new_subs[16]; // $s_zipcode =$new_subs[17]; // $s_phone =$new_subs[18]; // $login =ucwords($new_subs[19]); // $member_type =ucwords($new_subs[20]); // $use_lang =ucwords($new_subs[21]); // $fax =$new_subs[22]; // // $login =ucwords($new_subs[0]); $usertype =ucwords($new_subs[1]); $membership =$new_subs[2]; $password =text_crypt($new_subs[3]); $password_hint =$new_subs[4]; $password_hint_answer =$new_subs[5]; $b_address =ucwords($new_subs[6]); $b_address2 =ucwords($new_subs[7]); $b_city =ucwords($new_subs[8]); $b_state =$new_subs[9]; $b_country =$new_subs[10]; $b_zipcode =$new_subs[11]; $title =$new_subs[12]; $firstname =ucwords($new_subs[13]); $lastname =ucwords($new_subs[14]); $position =ucwords($new_subs[15]); $company =$new_subs[16]; $s_contact =$new_subs[17]; $s_address =ucwords($new_subs[18]); $s_address2 =ucwords($new_subs[19]); $s_city =ucwords($new_subs[20]); $s_state =$new_subs[21]; $s_country =$new_subs[22]; $s_zipcode =$new_subs[23]; $email =$new_subs[24]; $s_email =$new_subs[25]; $phone =$new_subs[26]; $s_phone =$new_subs[27]; $fax =$new_subs[28]; $s_fax =$new_subs[29]; $url =$new_subs[30]; $card_name =$new_subs[31]; $card_type =$new_subs[32]; $card_number =text_crypt($new_subs[33]); $card_expire =$new_subs[34]; $card_cvv2 =$new_subs[35]; $last_login =$new_subs[36]; $first_login =$new_subs[37]; $status =$new_subs[38]; $referer =$new_subs[39]; $pending_membership =$new_subs[40]; $ssn =$new_subs[41]; $tax_id =$new_subs[42]; $language =ucwords($new_subs[43]); /** // i used this for testing before import echo $login." "; echo $usertype." "; echo $membership." "; echo $password." "; echo $password_hint." "; echo $password_hint_answer." "; echo $b_address." "; echo $b_address2." "; echo $b_city." "; echo $b_state." "; echo $b_country." "; echo $b_zipcode." "; echo $title." "; echo $firstname." "; echo $lastname." "; echo $b_position." "; echo $company." "; echo $s_address." "; echo $s_address2." "; echo $s_city." "; echo $s_state." "; echo $s_ccountry." "; echo $s_zipcode." "; echo $email." "; echo $s_email." "; echo $phone." "; echo $s_phone." "; echo $s_name." "; echo $fax." "; echo $s_fax." "; echo $url." "; echo $card_name." "; echo $card_type." "; echo $card_number." "; echo $card_expire." "; echo $card_cvv2." "; echo $last_login." "; echo $first_login." "; echo $status." "; echo $referer." "; echo $pedning_membership." "; echo $ssn." "; echo $tax_id." "; echo $language." "; echo " "; **/ add_user($login, $usertype, $membership, $password, $password_hint, $password_hint_answer, $b_address, $b_address2, $b_city, $b_state, $b_country, $b_zipcode, $title, $firstname, $lastname, $b_position, $company, $s_contact, $s_address, $s_address2, $s_city, $s_state, $s_country, $ $s_zipcode, $email, $s_email, $phone, $s_phone, $fax, $s_fax, $url, $card_name, $card_type, $card_number, $card_expire, $card_cvv2, $last_login, $first_login, $status, $referer, $pending_membership, $ssn, $tax_id, $language); } // close database mysql_close(); echo "<h1>Import was completed!</h1>"; exit; function add_user($login, $usertype, $membership, $password, $password_hint, $password_hint_answer, $b_address, $b_address2, $b_city, $b_state, $b_country, $b_zipcode, $title, $firstname, $lastname, $b_position, $company, $s_contact, $s_address, $s_address2, $s_city, $s_state, $s_country, $s_zipcode, $email, $s_email, $phone, $s_phone, $fax, $s_fax, $url, $card_name, $card_type, $card_number, $card_expire, $card_cvv2, $last_login, $first_login, $status, $referer, $pending_membership, $ssn, $tax_id, $language) { GLOBAL $customers_table, $maillist_table; $query = "INSERT INTO $customers_table (login, usertype, membership, password, password_hint, password_hint_answer, b_address, b_address2, b_city, b_state, b_country, b_zipcode, title, firstname, lastname, b_position, company, s_contact, s_address, s_address2, s_city, s_state, s_country, s_zipcode, email, s_email, phone, s_phone, fax, s_fax, url, card_name, card_type, card_number, card_expire, card_cvv2, last_login, first_login, status, referer, pending_membership, ssn, tax_id, language) VALUES (\"$login\", \"$usertype\", \"$membership\", \"$password\", \"$password_hint\", \"$password_hint_answer\", \"$b_address\", \"$b_address2\", \"$b_city\", \"$b_state\", \"$b_country\", \"$b_zipcode\", \ "$title\", \"$firstname\", \"$lastname\", \"$b_position\", \"$company\", \"$s_contact\", \"$s_address\", \"$s_address2\", \"$s_city\", \"$s_state\", \"$s_country\", \"$s_zipcode\", \"$email\", \"$s_email\", \"$phone\", \"$s_phone\", \"$fax\", \"$s_fax\", \"$url\", \"$card_name\", \"$card_type\", \"$card_number\", \"$card_expire\", \"$card_cvv2\", \"$last_login\", \"$first_login\", \"$status\", \"$referer\", \"$pending_membership\", \"$ssn\", \"$tax_id\", \"$language\")"; $result = @mysql_query($query) or print(" Couldn't add user: ".$email); $query = "INSERT INTO $maillist_table (email, since_date) VALUES (\"$email\", \"$first_login\")"; $result = @mysql_query($query) or print(" Couldn't add email: ".$email); $query = "INSERT INTO $maillist_table (s_email, since_date) VALUES (\"$s_email\", \"$first_login\")"; $result = @mysql_query($query) or print(" Couldn't add email: ".$s_email); } // add_user ?>

Now - I have added several EXTRA FIELDS which is a different mod altogether. But this is the concept....

The fields added are for ship to additional info - like phone, fax, email - so I changed the code to add the second email to the email list table.

IT WORKS - BUT - the delimiter for the input file is a problem for me. several fields will be entered into 1 MySQL table field.

Im no coder but i know enough to be a pain in the A$$.
I cant remember what file type to use for import... any help here?
__________________
X-Cart V3.3.6 - w/ Product Import Mod
Unix
---------------------------------------------
Currently migrating to V4.0.11
Reply With Quote