adding a new row, getting duplicate error

dmikester1's profile image dmikester1 posted 8 years ago in General Permalink

I'm not sure what I am doing wrong here. I have a table with 8 columns and the first is a primary, auto increment key. I am entering rows manually from the interface. I add one row in just fine. When I add in the second row, it says "SQL Error (1062): Duplicate entry '0' for key 'PRIMARY'" the generated sql code in the bottom pane does not have the primary key in it. Here is the SQL code: INSERT INTO brochures (Name, DBName, Year, Description, Featured, Order) VALUES ('Simply Spring', 'SimplySpring', '2016', 'Our biggest shopper brochure with an extensive list of products for everyone. ', '1', '1');

BubikolRamios's profile image BubikolRamios posted 8 years ago Permalink

Add table crete code here.

dmikester1's profile image dmikester1 posted 8 years ago Permalink

Just remembered I was still having this issue. Here is my create code:

CREATE TABLE `brochures` (
    `BrochureID` SMALLINT(4) UNSIGNED NOT NULL,
    `Name` VARCHAR(50) NOT NULL COLLATE 'utf8_general_ci',
    `DBName` VARCHAR(50) NOT NULL COLLATE 'utf8_general_ci',
    `Year` SMALLINT(5) UNSIGNED NOT NULL,
    `Description` VARCHAR(250) NOT NULL COLLATE 'utf8_general_ci',
    `Active` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1',
    `Featured` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
    `Order` TINYINT(3) UNSIGNED NOT NULL,
    PRIMARY KEY (`BrochureID`),
    INDEX `Index 2` (`BrochureID`)
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=MyISAM
;
dmikester1's profile image dmikester1 posted 8 years ago Permalink

Nevermind, after posting that "create code" I noticed my id was not set to auto increment. I can add now after changing that.

Please login to leave a reply, or register at first.