Foros del Web » Programando para Internet » PHP »

error Duplicate entry '0' (1062)

Estas en el tema de error Duplicate entry '0' (1062) en el foro de PHP en Foros del Web. hola: tengo el siguiente inconveniente, tengo una tabla talents que para ingresar un registro debe tener el mismo id que la tabla pretalent, yo hice ...
  #1 (permalink)  
Antiguo 21/02/2008, 14:05
Avatar de destor77  
Fecha de Ingreso: noviembre-2004
Ubicación: Gálvez, Santa Fe, Argentina
Mensajes: 2.654
Antigüedad: 19 años, 5 meses
Puntos: 43
error Duplicate entry '0' (1062)

hola:
tengo el siguiente inconveniente, tengo una tabla talents que para ingresar un registro debe tener el mismo id que la tabla pretalent, yo hice un formulario donde paso el id de la tabla pretalent
quiero insertarlo asi:
Código PHP:
INSERT INTO `talents` (`prereg_id` ,`fr_id` ,`agent_fr_id` ,`rating` , `bio` , `feedback` , `w9_date` , `background_check_date` , `background_pass` , `drug_test_date` , `drug_test_pass` , `recruiter_commission` , `registration_status` ) VALUES '$_post[id]''''''''''''''''''''''''' 
la cuestion es que la primera vez me deja pero ya despues y me tira este error:

Duplicate entry '0' for key 2Duplicate entry '0' for key 2I

yo lo unico que quiero es ingresar solamente el id de la tabla preger en talent

la tabla tiene esta estructura:
Código:
CREATE TABLE `talents` (
  `prereg_id` bigint(20) NOT NULL,
  `fr_id` bigint(20) NOT NULL,
  `agent_fr_id` bigint(20) NOT NULL,
  `rating` int(11) NOT NULL,
  `bio` varchar(255) NOT NULL,
  `feedback` varchar(255) NOT NULL,
  `w9_date` date NOT NULL,
  `background_check_date` date NOT NULL,
  `background_pass` tinyint(1) NOT NULL,
  `drug_test_date` date NOT NULL,
  `drug_test_pass` tinyint(1) NOT NULL,
  `recruiter_commission` float NOT NULL,
  `registration_status` int(11) NOT NULL,
  PRIMARY KEY  (`prereg_id`),
  UNIQUE KEY `fr-id` (`fr_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
como puedo hacer para seguir agregado mas datos?

desde ya muchas gracias
  #2 (permalink)  
Antiguo 21/02/2008, 15:26
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Re: error Duplicate entry '0' (1062)

Tu problema es que estas "duplicando" tu primary key, y eso no lo podrás hacer, necesitas tener otra columna que sea tu primare key, y que sea de preferencia auto-increment, y luego aparte tener una llave foránea que sea tu prereg_id.

Saludos.
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 00:51.