M
M
MrChen2016-06-29 16:09:17
MySQL
MrChen, 2016-06-29 16:09:17

Why does an error pop up when executing a request?

Hello! When executing a SQL query in Laravel, an error pops up:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'users_username_unique' (SQL: insert into `users` (`email`, `password`, `activationCode`, `isActive`, `updated_at`, `created_at`) values ([email protected], y$KYlaTrJ4JlItR3BTQT81D.el3mt4A.Uam9DvG.6FFLKBohCaGPxQC, CMo0BXN3Dj6cM3pV, 0, 2016-06-29 13:06:38, 2016-06-29 13:06:38))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2016-06-29
@MrChen

You have a users_username_unique field in your table that has a unique index applied to it.
The table already has an entry with users_username_unique = "".
You are inserting into this table without specifying this field, so an error occurs - an attempt to create another record with users_username_unique = "".

R
Rsa97, 2016-06-29
@Rsa97

Trying to create a record with a duplicate of the unique field `username` = ''

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question