title: What does 'Execute failed: (1062) Duplicate entry 'X' for key 'Y'' mean?
body: <p>I am trying to add <code>X</code> to some table in my DB, but I am getting this error. Even if <code>X</code> doesn't exist in the table, it say it's there. Although <code>X</code> is added to the DB, I want to get rid of this error. I don't know if it's relevant at all, but I'm using Mysqli's prepared statements and this error is printed using <code>$statement-&gt;errno." ".$statement-&gt;error</code>. Could someone explain this to me? Thanks.</p>
  
  <p>UPDATE: this is the code:  <code>X = USER_USERNAME</code></p>
  
  <pre><code>$stmt = $mysqli-&gt;prepare("INSERT INTO USERS (USER_USERNAME, USER_EMAIL, USER_BIRTHDAY, USER_PASSWORD, USER_SALT, USER_IP, USER_ACTIVATION_CODE) VALUES (?,?,?,?,?,INET_ATON(?),?)");
              $stmt-&gt;bind_param('sssssss',$username,$email,$date,$hashed_password,$salt,$IP,$activation_code);
              $stmt-&gt;execute();
              if (!$stmt-&gt;execute()) {
                  echo "Execute failed: (" . $stmt-&gt;errno . ") " . $stmt-&gt;error;
              }
              else {
                  echo "ok";
              }
  </code></pre>
  
  <p>SHOW CREATE TABLE USERS:</p>
  
  <pre><code> CREATE TABLE `USERS` (
   `USER_ID` int(11) NOT NULL AUTO_INCREMENT,
   `USER_FIRSTNAME` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
   `USER_LASTNAME` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
   `USER_USERNAME` varchar(30) CHARACTER SET utf8 DEFAULT NULL,
   `USER_PASSWORD` varchar(128) CHARACTER SET utf8 DEFAULT NULL,
   `LEVEL_ID` int(11) NOT NULL,
   `USER_BIRTHDAY` date DEFAULT NULL,
   `USER_EMAIL` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
   `USER_GENDER` enum('M','W','U') CHARACTER SET utf8 DEFAULT NULL,
   `USER_COUNTRY` varchar(30) CHARACTER SET utf8 DEFAULT NULL,
   `USER_LOCATION` varchar(30) CHARACTER SET utf8 DEFAULT NULL,
   `USER_ADDRESS` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
   `USER_HOUSENUMBER` varchar(8) CHARACTER SET utf8 DEFAULT NULL,
   `USER_AVATAR` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
   `USER_REGISTRATION_DATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `USER_ACTIVATION_DATE` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
   `USER_STATUS` enum('REGISTERED','ACTIVE','BANNED','NONACTIVE') CHARACTER SET utf8 DEFAULT NULL,
   `USER_BANNED_DATE` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
   `USER_LATEST_LOGIN` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
   `USER_EXP` bigint(20) DEFAULT NULL,
   `USER_DESCRIPTION` text CHARACTER SET utf8,
   `USER_ACTIVATION_CODE` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '0',
   `USER_SALT` varchar(15) CHARACTER SET utf8 NOT NULL,
   `USER_IP` int(10) NOT NULL,
   `USER_REMEMBER_KEY` varchar(32) CHARACTER SET utf8 NOT NULL,
   PRIMARY KEY (`USER_ID`),
   UNIQUE KEY `USER_USERNAME` (`USER_USERNAME`),
   UNIQUE KEY `USER_EMAIL` (`USER_EMAIL`),
   KEY `LEVEL_ID` (`LEVEL_ID`)
  ) ENGINE=MyISAM AUTO_INCREMENT=30 DEFAULT CHARSET=latin1
  </code></pre>