Jump to content

Archived

This topic is now archived and is closed to further replies.

localhost

Duplicate Entry For Key1?

Recommended Posts

[code]$query = "INSERT INTO `content` ( `id` , `parentid` , `order` , `text` , `date` , `alttext` , `icon` , `type` , `status` , `permission` , `poster` , `mod` , `count1` , `count2` ) VALUES ('0', '-1', '1', 'Powered by dotOmega', '0000-00-00', '', '', '0', '0', '1', '0', '0', '0', '0');";



$result = mysql_query($query) or die('Query failed: ' . mysql_error() . '<hr><b>Error: E004</b>');

$query = "INSERT INTO `content` (`id`, `parentid`, `order`, `text`, `date`, `alttext`, `icon`, `type`, `status`, `permission`, `poster`, `mod`, `count1`, `count2`) VALUES ('1', '0', '1', 'Your dotOmega Forum', '$date', 'Thank you for installing dotOmega Forum System, you may edit this forum to your liking.', '', '2', '0', '1', '','', '', '')";

$result = mysql_query($query) or die(mysql_error());[/code]

thats the code and heres the error:

Duplicate entry '1' for key 1

Share this post


Link to post
Share on other sites
[!--quoteo(post=388557:date=Jun 27 2006, 01:08 PM:name=localhost)--][div class=\'quotetop\']QUOTE(localhost @ Jun 27 2006, 01:08 PM) [snapback]388557[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]$query = "INSERT INTO `content` ( `id` , `parentid` , `order` , `text` , `date` , `alttext` , `icon` , `type` , `status` , `permission` , `poster` , `mod` , `count1` , `count2` ) VALUES ('0', '-1', '1', 'Powered by dotOmega', '0000-00-00', '', '', '0', '0', '1', '0', '0', '0', '0');";
$result = mysql_query($query) or die('Query failed: ' . mysql_error() . '<hr><b>Error: E004</b>');

$query = "INSERT INTO `content` (`id`, `parentid`, `order`, `text`, `date`, `alttext`, `icon`, `type`, `status`, `permission`, `poster`, `mod`, `count1`, `count2`) VALUES ('1', '0', '1', 'Your dotOmega Forum', '$date', 'Thank you for installing dotOmega Forum System, you may edit this forum to your liking.', '', '2', '0', '1', '','', '', '')";

$result = mysql_query($query) or die(mysql_error());[/code]

thats the code and heres the error:

Duplicate entry '1' for key 1
[/quote]

DB structure is one of your fields primary Key (maybe ID) and 1 is already definded and there are no dup's definded for the field..... I would check your DB structure on this one

Share this post


Link to post
Share on other sites
I think your id column is auto_increment.

So in your queries do this for example:
INSERT INTO `content` ( `id` , `parentid` , `order` , `text` , `date` , `alttext` , `icon` , `type` , `status` , `permission` , `poster` , `mod` , `count1` , `count2` ) VALUES ([b]''[/b],....

Orio.

Share this post


Link to post
Share on other sites
Thanks Orio, it was due to auto increment, using just '' as opposed to '1' worked wonderfully.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.