Results 1 to 4 of 4
  1. #1
    Join Date
    May 2007
    Posts
    2
    Plugin Contributions
    0

    Default SQL Error : 1062 Duplicate entry '0' for key 1

    Hmm i just imported a db due to switching hosts for my website/forum and i have this problem when posting

    Code:
     			 			 				Error in posting
    
    DEBUG MODE
    
    SQL Error : 1062 Duplicate entry '0' for key 1
    
    INSERT INTO phpbb_topics (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('ss', 2, 1178195754, 16, 0, 0, 0)
    
    Line : 227
    File : functions_post.php
    Can someone help ? thanks.

  2. #2
    Join Date
    Nov 2006
    Location
    Papworth, Cambridgeshire, UK
    Posts
    731
    Plugin Contributions
    3

    Default Re: SQL Error : 1062 Duplicate entry '0' for key 1

    Usually means your database backup did not include 'auto increment' on the key fields, or that it was not part of the database create.
    Requires you to edit/alter the database so those fields affected are once again auto incrementing.

  3. #3
    Join Date
    May 2007
    Posts
    2
    Plugin Contributions
    0

    Default Re: SQL Error : 1062 Duplicate entry '0' for key 1

    Hmm Which file , would would it be just funtions_posts.php? or others?

    besides im not sure what i would have to do exactly in the edit to increment like u mentioned?

    Help

  4. #4
    Join Date
    Nov 2006
    Location
    Papworth, Cambridgeshire, UK
    Posts
    731
    Plugin Contributions
    3

    Default Re: SQL Error : 1062 Duplicate entry '0' for key 1

    Er no, your Mysql database for your Zen Cart installation is the culprit. Or, your backup of your original site on the other server is the culprit. If you look at the backup file from your original site, it is full of SQL statements such as

    DROP TABLE IF EXISTS `address_book`;
    CREATE TABLE `address_book` (
    `address_book_id` int(11) NOT NULL auto_increment,

    followed by a whole lot of other fields, and at the end something like

    ENGINE=MyISAM AUTO_INCREMENT=24 DEFAULT CHARSET=latin1;

    The above sets address_book_id as an auto incrementing field, and the last line says there are 24 entries already, so carry on from there

    However, I usually SQLyog for such things, and instead, it creates

    DROP TABLE IF EXISTS `address_book`;

    CREATE TABLE `address_book` (
    `address_book_id` int(11) NOT NULL,

    in the backup file, omitting the auto increment.
    When you attempt to add something, it fails because it is trying to use a key index of 0, which already exists.
    To fix this, you have to edit the database, or edit the backup file, to add the auto increment where needed, which is just about everywhere.

 

 

Similar Threads

  1. DB Import Error #1062 - Duplicate entry '1' for key 1
    By aushy in forum Installing on a Windows Server
    Replies: 6
    Last Post: 19 Oct 2011, 11:38 AM
  2. SQL Errors when importing to new database - #1062 - Duplicate entry '3' for key 1
    By countingsheep in forum Upgrading from 1.3.x to 1.3.9
    Replies: 3
    Last Post: 17 Sep 2009, 09:43 PM
  3. 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a
    By Ellume in forum Upgrading from 1.3.x to 1.3.9
    Replies: 24
    Last Post: 10 Jun 2008, 07:34 AM
  4. Error: 1062 Duplicate entry '0-78' for key 1
    By G33K-Chik in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 15 Apr 2008, 08:47 PM
  5. Replies: 2
    Last Post: 20 Oct 2006, 09:49 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