Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2009
    Posts
    2,123
    Plugin Contributions
    0

    Default Database Errors - Duplicate Entries - How Did You Hear About Us Mod

    When I have "How did you hear about us" mod installed, I get this wierd error when I create a new account:

    1062 Duplicate entry '765' for key 1
    in:
    [insert into customers_info (customers_info_id, customers_info_number_of_logons, customers_info_date_account_created, customers_info_source_id) values ('765', '0', now(), '1')]


    I ran the SQL patch that came with the mod, I ran it via "phpMyAdmin" and it gave an error as soon as I did, it said:

    Error

    SQL query:

    ALTER TABLE customers_info ADD customers_info_source_id int NOT NULL AFTER customers_info_date_account_last_modified;

    MySQL said: Documentation
    #1060 - Duplicate column name 'customers_info_source_id'


    Here is the SQL patch that I applied:

    PHP Code:
    DROP TABLE IF EXISTS sources;
    CREATE TABLE sources (
      
    sources_id int NOT NULL auto_increment,
      
    sources_name varchar(64NOT NULL,
      
    PRIMARY KEY (sources_id),
      
    KEY IDX_SOURCES_NAME (sources_name)
    );

    INSERT INTO sources VALUES (1'Google');
    INSERT INTO sources VALUES (2'Yahoo!');
    INSERT INTO sources VALUES (3'AOL');
    INSERT INTO sources VALUES (4'MSN');
    INSERT INTO sources VALUES (5'ZenCart');

    DROP TABLE IF EXISTS sources_other;
    CREATE TABLE sources_other (
      
    customers_id int NOT NULL default '0',
      
    sources_other_name varchar(64NOT NULL,
      
    PRIMARY KEY (customers_id)
    );

    ALTER TABLE customers_info ADD customers_info_source_id int NOT NULL AFTER customers_info_date_account_last_modified;


    INSERT INTO configuration (configuration_titleconfiguration_keyconfiguration_valueconfiguration_descriptionconfiguration_group_idsort_orderset_functiondate_addedVALUES ('Display "Other" Referral option''DISPLAY_REFERRAL_OTHER''true''Display "Other - please specify" with text box in referral source in account creation''1''22''zen_cfg_select_option(array(\'true\', \'false\'), 'now());
    INSERT INTO configuration (configuration_titleconfiguration_keyconfiguration_valueconfiguration_descriptionconfiguration_group_idsort_orderset_functiondate_addedVALUES ('Require Referral''REFERRAL_REQUIRED''true''Require the Referral Source in account creation''5''6''zen_cfg_select_option(array(\'true\', \'false\'), 'now()); 
    So, could anyone please be so kind as to tell me how to reverse this SQL patch? More to the point, why after running the patch do I get the 1062 Duplicate entry '765' for key 1 error?

  2. #2
    Join Date
    May 2010
    Posts
    36
    Plugin Contributions
    0

    Default Re: Database Errors - Duplicate Entries - How Did You Hear About Us Mod

    I too am receiving this error after i've just installed this mod, however mine is "1062 Duplicate entry '1' for key 'PRIMARY'"
    I receive it when i try and create an account

  3. #3
    Join Date
    May 2010
    Posts
    36
    Plugin Contributions
    0

    Default Re: Database Errors - Duplicate Entries - How Did You Hear About Us Mod

    Couldnt edit my post but i've found a fix.

    In /includes/modules/create_account.php (you may have this file in YOUR_TEMPLATE folder) i believe either by lack of instruction or concentration there was a block of code which i needed to delete.

    Around line 329 you should have code that looks like this:
    //rmh referral start
    $query_insert= "insert into " . TABLE_CUSTOMERS_INFO . " (customers_info_id, customers_info_number_of_logons, customers_info_date_account_created, customers_info_source_id) values ('" . (int)$_SESSION['customer_id'] . "', '0', now(), '". (int)$source . "')";

    $sql = "insert into " . TABLE_CUSTOMERS_INFO . "
    (customers_info_id, customers_info_number_of_logons,
    customers_info_date_account_created, customers_info_date_of_last_logon)
    values ('" . (int)$_SESSION['customer_id'] . "', '1', now(), now())";
    $db->Execute($query_insert);

    $db->Execute($sql);
    If you delete:
    $sql = "insert into " . TABLE_CUSTOMERS_INFO . "
    (customers_info_id, customers_info_number_of_logons,
    customers_info_date_account_created, customers_info_date_of_last_logon)
    values ('" . (int)$_SESSION['customer_id'] . "', '1', now(), now())";
    It should work for you. If you examine the code you can see that the data is being inserted to the database twice.

    Hope this helps people

  4. #4
    Join Date
    Jan 2009
    Posts
    2,123
    Plugin Contributions
    0

    Default Re: Database Errors - Duplicate Entries - How Did You Hear About Us Mod

    Hi yeah, I meant to add a response to this last nigth but I was too tired by the tme I'd solved it. Like you, it turned out that another modification in my create_account.php was writing to the same table. In my case it was the 'COWA' mod. I just deleted the duplicate lines from the file and voila, the new mod worked perfectly.

 

 

Similar Threads

  1. How Did You Hear About Us? Referrals Mod [Support Thread]
    By martyndw2005 in forum All Other Contributions/Addons
    Replies: 358
    Last Post: 9 May 2025, 07:25 PM
  2. How Did You Hear About Us? mod
    By yeah! in forum All Other Contributions/Addons
    Replies: 15
    Last Post: 28 Dec 2011, 06:28 PM
  3. How Did You Hear About Us Mod...2 Instances Possible??
    By jdw1979 in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 26 Mar 2010, 02:14 PM
  4. Replies: 2
    Last Post: 23 Jul 2009, 02:11 PM
  5. Error in admin - PayPal - when using How Did You Hear About us mod
    By TrvlFox in forum PayPal Express Checkout support
    Replies: 3
    Last Post: 23 Nov 2007, 03:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR