Jump to content


Photo

Duplicate Entry For Key1?


  • Please log in to reply
3 replies to this topic

#1 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 27 June 2006 - 05:08 PM

$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());

thats the code and heres the error:

Duplicate entry '1' for key 1

#2 jvrothjr

jvrothjr
  • Members
  • PipPipPip
  • Advanced Member
  • 300 posts
  • LocationOhio

Posted 27 June 2006 - 05:21 PM

[!--quoteo(post=388557:date=Jun 27 2006, 01:08 PM:name=localhost)--][div class=\'quotetop\']QUOTE(localhost @ Jun 27 2006, 01:08 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
$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());

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

If you understand everything you know nothing!

http://rcchjr.awardspace.com/

#3 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 27 June 2006 - 05:24 PM

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 ('',....

Orio.
Think you're smarty?

(Gone until 20 to November)

#4 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 27 June 2006 - 11:45 PM

Thanks Orio, it was due to auto increment, using just '' as opposed to '1' worked wonderfully.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users