Page 1 of 1

Man... I feel like such a noob. "Duplicate Key" e

Posted: Wed May 19, 2004 12:08 am
by Steveo31
I don't think thats a bad thing, but nonetheless, I looked up the solution to this prob with no avail.

That stupid error of "duplicate key '0' in" or whatever came up.

DB:

Code: Select all

CREATE TABLE `articles` (
  `id` int(5) NOT NULL auto_increment,
  `title` varchar(50) NOT NULL default '',
  `body` text NOT NULL,
  `author` varchar(40) NOT NULL default '',
  `dateadd` datetime NOT NULL default '0000-00-00 00:00:00',
  `rating` tinyint(2) NOT NULL default '0',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `rating` (`rating`),
  KEY `author` (`author`),
  FULLTEXT KEY `body` (`body`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
Insert code:

Code: Select all

$insert = mysql_query("INSERT INTO `articles` (`title`, `body`, `author`, `dateadd`) VALUES ('$title', '$body', '$author', NOW())");
:?

Posted: Wed May 19, 2004 12:14 am
by feyd
rating is a unique key.. and you aren't setting it. It's default is 0.. so yeah..

Posted: Thu May 20, 2004 12:21 am
by Steveo31
Doh.

Thanks :)

Posted: Thu May 20, 2004 12:30 am
by feyd
hehe easy mistake. ;)