Error including in database: Duplicate entry '-1' for key 'PRIMARY'

Asked

Viewed 178 times

0

Friends have this table, when I save a user the following error occurs

Error including in database: Duplicate entry 'first name.last name -1' for key 'PRIMARY'

This is the code. detail in development works, not in production.

CREATE TABLE `usuarios` (
  `login` varchar(255) NOT NULL,
  `passe` varchar(255) NOT NULL,
  `nome` varchar(64) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `active` varchar(1) DEFAULT NULL,
  `activation_code` varchar(32) DEFAULT NULL,
  `admin_pv` varchar(1) DEFAULT NULL,
  `foto` longblob,
  `img_user` varchar(256) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `usuarios`
  ADD PRIMARY KEY (`login`);
  • the error message is clear, is trying to enter again the same 'name.surname -1' value for the field that is primary key

  • yeah. but the bank is empty.

  • show the command insert which you are using. the message is clear, you have certainly tried to include more than once the same record with the same value. See the example here that I did and it does not give error the Insert in the table with this structure: http://sqlfiddle.com/#! 9/9c2797/1

  • Solved, the problem was another Insert that had put to another table and there this user was already.

  • didn’t you say the message was clear? ;) good luck

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.