Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » Mysql »

Error: Duplicate entry '1' for key 'PRIMARY'

Estas en el tema de Error: Duplicate entry '1' for key 'PRIMARY' en el foro de Mysql en Foros del Web. Podrían decirme por favor donde se encuentra el error!? @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código MySQL: Ver original CREATE TABLE IF NOT EXISTS `nuke _ users` (   ...
  #1 (permalink)  
Antiguo 22/03/2015, 01:10
 
Fecha de Ingreso: septiembre-2008
Mensajes: 20
Antigüedad: 15 años, 7 meses
Puntos: 0
Pregunta Error: Duplicate entry '1' for key 'PRIMARY'

Podrían decirme por favor donde se encuentra el error!?
Código MySQL:
Ver original
  1. CREATE TABLE IF NOT EXISTS `nuke_users` (  
  2.   `user_id` int(11) NOT NULL AUTO_INCREMENT,
  3.   `warned` int(1) NOT NULL DEFAULT '0',
  4.   `user_joined` int(20) NOT NULL,
  5.   `name` varchar(60) NOT NULL DEFAULT '',
  6.   `username` varchar(25) NOT NULL DEFAULT '',
  7.   `user_email` varchar(255) NOT NULL DEFAULT '',
  8.   `user_room` varchar(100) NOT NULL,
  9.   `last_active` int(20) NOT NULL DEFAULT '0',
  10.   `last_msg` int(20) NOT NULL DEFAULT '0',
  11.   `active` int(1) NOT NULL DEFAULT '0',
  12.   `rank` int(1) NOT NULL DEFAULT '1',
  13.   `apanel` int(1) NOT NULL DEFAULT '0',
  14.   `kicked` int(1) NOT NULL DEFAULT '0',
  15.   `banned` int(1) NOT NULL DEFAULT '0',
  16.   `reset` int(1) NOT NULL DEFAULT '0',
  17.   `warning_text` varchar(300) NOT NULL DEFAULT 'Never Warned',
  18.   `profile_age` int(3) NOT NULL DEFAULT '0',
  19.   `profile_sex` int(1) NOT NULL DEFAULT '0',
  20.   `profile_bio` varchar(300) NOT NULL DEFAULT '0',
  21.   `profile_avatar` varchar(100) NOT NULL DEFAULT 'no_avatar.jpg',
  22.   `last_poll` varchar(25) NOT NULL DEFAULT '0',
  23.   `private_poll` varchar(25) NOT NULL DEFAULT '0',
  24.   `profile_location` varchar(100) NOT NULL DEFAULT 'Unknown',
  25.   `user_ip` varchar(30) NOT NULL,
  26.   `femail` varchar(255) NOT NULL DEFAULT '',
  27.   `user_website` varchar(255) NOT NULL DEFAULT '',
  28.   `user_avatar` varchar(255) NOT NULL DEFAULT '',
  29.   `user_regdate` varchar(20) NOT NULL DEFAULT '',
  30.   `user_icq` varchar(15) DEFAULT NULL,
  31.   `user_occ` varchar(100) DEFAULT NULL,
  32.   `user_from` varchar(100) DEFAULT NULL,
  33.   `user_interests` varchar(150) NOT NULL DEFAULT '',
  34.   `user_sig` varchar(255) DEFAULT NULL,
  35.   `user_viewemail` tinyint(2) DEFAULT NULL,
  36.   `user_theme` int(3) DEFAULT NULL,
  37.   `user_aim` varchar(18) DEFAULT NULL,
  38.   `user_yim` varchar(25) DEFAULT NULL,
  39.   `user_msnm` varchar(25) DEFAULT NULL,
  40.   `user_password` varchar(40) NOT NULL DEFAULT '',
  41.   `storynum` tinyint(4) NOT NULL DEFAULT '10',
  42.   `umode` varchar(10) NOT NULL DEFAULT '',
  43.   `uorder` tinyint(1) NOT NULL DEFAULT '0',
  44.   `thold` tinyint(1) NOT NULL DEFAULT '0',
  45.   `noscore` tinyint(1) NOT NULL DEFAULT '0',
  46.   `bio` tinytext NOT NULL,
  47.   `ublockon` tinyint(1) NOT NULL DEFAULT '0',
  48.   `ublock` tinytext NOT NULL,
  49.   `theme` varchar(255) NOT NULL DEFAULT '',
  50.   `commentmax` int(11) NOT NULL DEFAULT '4096',
  51.   `counter` int(11) NOT NULL DEFAULT '0',
  52.   `newsletter` int(1) NOT NULL DEFAULT '0',
  53.   `user_posts` int(10) NOT NULL DEFAULT '0',
  54.   `user_attachsig` int(2) NOT NULL DEFAULT '0',
  55.   `user_rank` int(10) NOT NULL DEFAULT '0',
  56.   `user_level` int(10) NOT NULL DEFAULT '1',
  57.   `broadcast` tinyint(1) NOT NULL DEFAULT '1',
  58.   `popmeson` tinyint(1) NOT NULL DEFAULT '0',
  59.   `user_active` tinyint(1) DEFAULT '1',
  60.   `user_session_time` int(11) NOT NULL DEFAULT '0',
  61.   `user_session_page` smallint(5) NOT NULL DEFAULT '0',
  62.   `user_lastvisit` int(11) NOT NULL DEFAULT '0',
  63.   `user_timezone` tinyint(4) NOT NULL DEFAULT '10',
  64.   `user_style` tinyint(4) DEFAULT NULL,
  65.   `user_lang` varchar(255) NOT NULL DEFAULT 'english',
  66.   `user_dateformat` varchar(14) NOT NULL DEFAULT 'D M d, Y g:i a',
  67.   `user_new_privmsg` smallint(5) unsigned NOT NULL DEFAULT '0',
  68.   `user_unread_privmsg` smallint(5) unsigned NOT NULL DEFAULT '0',
  69.   `user_last_privmsg` int(11) NOT NULL DEFAULT '0',
  70.   `user_emailtime` int(11) DEFAULT NULL,
  71.   `user_allowhtml` tinyint(1) DEFAULT '1',
  72.   `user_allowbbcode` tinyint(1) DEFAULT '1',
  73.   `user_allowsmile` tinyint(1) DEFAULT '1',
  74.   `user_allowavatar` tinyint(1) NOT NULL DEFAULT '1',
  75.   `user_allow_pm` tinyint(1) NOT NULL DEFAULT '1',
  76.   `user_allow_viewonline` tinyint(1) NOT NULL DEFAULT '1',
  77.   `user_notify` tinyint(1) NOT NULL DEFAULT '0',
  78.   `user_notify_pm` tinyint(1) NOT NULL DEFAULT '0',
  79.   `user_popup_pm` tinyint(1) NOT NULL DEFAULT '0',
  80.   `user_avatar_type` tinyint(4) NOT NULL DEFAULT '3',
  81.   `user_sig_bbcode_uid` varchar(10) DEFAULT NULL,
  82.   `user_actkey` varchar(32) DEFAULT NULL,
  83.   `user_newpasswd` varchar(32) DEFAULT NULL,
  84.   `points` int(10) DEFAULT '0',
  85.   `last_ip` varchar(15) NOT NULL DEFAULT '0',
  86.   `sexo` int(11) NOT NULL DEFAULT '0',
  87.   `user_group_cp` int(11) NOT NULL DEFAULT '2',
  88.   `user_group_list_cp` varchar(100) NOT NULL DEFAULT '2',
  89.   `user_active_cp` enum('YES','NO') NOT NULL DEFAULT 'YES',
  90.   `user_lastvisit_cp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  91.   `user_regdate_cp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  92.   PRIMARY KEY (`user_id`),
  93.       KEY `uid` (`user_id`),
  94.   KEY `uname` (`username`),
  95.   KEY `user_session_time` (`user_session_time`)
  96. ) ENGINE=UnnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=125 ;

Última edición por gnzsoloyo; 22/03/2015 a las 06:33
  #2 (permalink)  
Antiguo 22/03/2015, 05:54
Avatar de gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 4 meses
Puntos: 2658
Respuesta: Error: Duplicate entry '1' for key 'PRIMARY'

Es un error en el INSERT, no al crear la tabla.
Sin duda estás insertando el USER_ID, a pesar de ser un autoincremental.
Sería mejor no insertarlo y dejar que MySQL lo administre, pero con una tabla tan espantosamente larga (muy mal diseño), es probable que te cueste indicar uno a uno los campos, por lo que te recomiendo reemplazar ese valor por NULL.
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)

Última edición por gnzsoloyo; 22/03/2015 a las 06:35

Etiquetas: mysql-error, mysql-php
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:28.