user2353818
user2353818

Reputation:

MYSQLi/PHP allowing duplicate entry on UNIQUE?

I am having a very strange problem.

This is what i have, in my structure the "email" field is clearly set to unique. However when i try to register with a duplicate email, instead of giving me a fat error it lets it slide. My database is having two rows with the same email.. The problem isnt just for email, even though i have them all set to unique it allows any and every field to have duplicates.. Any suggestions as to why this may happen? The field is not set to allow null.

Upvotes: 0

Views: 1191

Answers (2)

John Woo
John Woo

Reputation: 263723

Your current table structure is

enter image description here

I can't see any unique key defined in the table that's why it is possible to have duplicate email, try this:

CREATE TABLE UserList
(
    ID INT AUTO_INCREMENT PRIMARY KEY NOT NULL,
    username VARCHAR(50) NOT NULL,
    email VARCHAR(50) NOT NULL,
    igname VARCHAR(50) NOT NULL,
    password VARCHAR(100) NOT NULL,
    verified VARCHAR(5) NOT NULL,
    CONSTRAINT email_uq UNIQUE (email)
);

Upvotes: 1

Your Common Sense
Your Common Sense

Reputation: 157872

MYSQLi/PHP allowing duplicate entry on UNIQUE?

Nope.
It is some mistake with your code or data.

Upvotes: 2

Related Questions