Give the following table:
CREATE TABLE User (
Email VARCHAR(256) PRIMARY KEY,
Name VARCHAR(256),
);
I am trying to insert date into the table. To check for duplication, should I use SQL to select email from user where email = $email and check the number or rows return is 1 and if it is 1, I just use php to print error message OR Should I just try to insert the data into table and use the following to print error?
mysql_query('INSERT INTO ...');
if (mysql_errno() == 1062) {
print 'no way!';
}
Which is a better way?