Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2011
    Posts
    12
    Plugin Contributions
    0

    Default 1062 Duplicate entry '5754' for key 'PRIMARY'

    Yep, I did something wrong and now I'm getting this message:

    1062 Duplicate entry '5754' for key 'PRIMARY'
    in:
    [insert into admin_activity_log (access_date, admin_id, page_accessed, page_parameters, ip_address) values (now(), '0', 'login.php ', '', '127.0.0.1')]

    now I can't login to my admin screen.

    Can someone tell me how to fix this or where to look for the answer.

    using:
    zen cart 1.3.9h
    php 5.3.4
    mysql 5.1.53

    running on a local host

    Thanks for the help.

    Neil

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: 1062 Duplicate entry '5754' for key 'PRIMARY'

    Quote Originally Posted by Pike Promo View Post
    Yep, I did something wrong
    WHAT exactly were you doing before that happened?
    Quote Originally Posted by Pike Promo View Post
    and now I'm getting this message:

    1062 Duplicate entry '5754' for key 'PRIMARY'
    in:
    [insert into admin_activity_log ...
    That suggests that someone has manually deleted entries from the database table, and/or has broken the auto_increment flag that's supposed to be set on the table. That sometimes happens when exporting/importing the database from a very old MySQL version to a much newer version, or vice-versa, without taking precautions to prevent that side-effect.
    And if you're deleting entries, I must ask: why?

    Quote Originally Posted by Pike Promo View Post
    Can someone tell me how to fix this or where to look for the answer.

    using:
    zen cart 1.3.9h
    php 5.3.4
    mysql 5.1.53

    running on a local host
    ONLY BECAUSE you're running on a localhost, and NOT on a live webserver where real customers are shopping, you can probably fix the problem by dropping and recreating the admin_activity_log table in your database.
    Warning, especially for future readers of this discussion: IF YOU ARE RUNNING ON A LIVE SITE, THEN YOU SHOULD **NEVER** drop or recreate or truncate that table without first making a backup of its contents, else you can get yourself in trouble for accounting and PCI and security reasons.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Jul 2011
    Posts
    12
    Plugin Contributions
    0

    Default Re: 1062 Duplicate entry '5754' for key 'PRIMARY'

    I was creating the text for a FAQ ezpage that I created. I would add some text update it check it in my browser and then go back and add some more text. Back and forth like that for awhile.

    I also, and I'm guessing this is the problem, added fckeditor. I ended up with an admin folder in addition to the original admin folder that I re-named when I first installed Zen Cart. Deleted this second admin folder (the one that installed with fckeditor) and it did not solve my problem.

    I'm more of a html and css guy than php and msql. I took the following from http://dev.mysql.com/doc/refman/5.1/...efinition.html

    Could I use it to drop and create my table.

    where tbl_name is admin_activity_log

    DROP [TEMPORARY] TABLE [IF EXISTS]
    tbl_name [, tbl_name] ...
    [RESTRICT | CASCADE]


    CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
    [(create_definition,...)]
    [table_options]
    select_statement

  4. #4
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: 1062 Duplicate entry '5754' for key 'PRIMARY'

    No. You need the correct original table structure. You said you're using v1.3.9h, so this would be the correct code for that:
    Code:
    DROP TABLE IF EXISTS admin_activity_log;
    CREATE TABLE admin_activity_log (
      log_id int(15) NOT NULL auto_increment,
      access_date datetime NOT NULL default '0001-01-01 00:00:00',
      admin_id int(11) NOT NULL default '0',
      page_accessed varchar(80) NOT NULL default '',
      page_parameters text,
      ip_address varchar(15) NOT NULL default '',
      PRIMARY KEY  (log_id),
      KEY idx_page_accessed_zen (page_accessed),
      KEY idx_access_date_zen (access_date),
      KEY idx_ip_zen (ip_address)
    ) ENGINE=MyISAM;
    Again ... Warning, especially for future readers of this discussion: IF YOU ARE RUNNING ON A LIVE SITE, THEN YOU SHOULD **NEVER** drop or recreate or truncate that table without first making a backup of its contents, else you can get yourself in trouble for accounting and PCI and security reasons.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Jul 2011
    Posts
    12
    Plugin Contributions
    0

    Default Re: 1062 Duplicate entry '5754' for key 'PRIMARY'

    DrByte

    THANK YOU I awoke this morning (I'm on the east coast of the USA) and rushed to my screen to see if I was right. Of course I wasn't but you hit it out of the park. I'm just starting all of this database stuff and WOW, I thought HTML and CSS looked strange. This stuff is much more complexed. I'll eventually get a handle on it though.

    ONLY BECAUSE you're running on a localhost, and NOT on a live webserver where real customers are shopping, you can probably fix the problem by dropping and recreating the admin_activity_log table in your database
    When you said the above why only because you're running on a localhost. It sounds like I could do it to a live site. It sounds like a security issue but why? If I was on a live site how would I have fixed it.?

    Lastly, How did you come up with that specific code. It sounds like you have a "bible" to look up code in. Zen cart version 1.3.9 admin_activity_log code and there it is.

    I'm trying to learn the principles behind all of this instead of just taking answers and running.

    Tonight I will be getting on with my storefront after a few down days. And it's because of this forums creation and your generosity. I can't say thank you enough times.

  6. #6
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: 1062 Duplicate entry '5754' for key 'PRIMARY'

    a) If you were running on a live site, I'd tell you to go through and do a backup of that table before dropping it (which deletes it), and store that backup in a safe place, so that you have the data records from that table as a reference in case you need it for audit purposes in case you were hacked. You can't defend yourself in an audit if you don't have the data. Plus, keeping that data is a requirement under the TOS of your payment provider arrangements, in most cases.

    b) I took that code from the master install script for ZC 1.3.9, from the main distribution zip file, which you can download from the home page of www.zen-cart.com . You should always have a copy of the code used on your site, kept on your PC not only for backup purposes but also for quick comparison and assessment and troubleshooting.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. v139a 1062 Duplicate entry '261228-7443 'for key' PRIMARY '
    By crb_style in forum General Questions
    Replies: 3
    Last Post: 6 Jun 2013, 02:06 PM
  2. v151 PHP Fatal error:1062:Duplicate entry '1-1' for key 'PRIMARY'
    By Dopefish in forum General Questions
    Replies: 14
    Last Post: 19 Oct 2012, 02:58 AM
  3. 1062 Duplicate entry '31' for key 'PRIMARY'
    By yisou in forum General Questions
    Replies: 1
    Last Post: 8 Apr 2012, 05:18 PM
  4. Replies: 1
    Last Post: 24 Feb 2011, 05:22 PM
  5. Error when importing DB - #1062 - Duplicate entry '1' for key 'PRIMARY'
    By CheapStairParts in forum General Questions
    Replies: 0
    Last Post: 5 Jan 2011, 03:10 AM

Bookmarks

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