reportingsjr Posted May 5, 2006 Share Posted May 5, 2006 I am creating a register out of php/sql and I have this coding: $query2 = "INSERT INTO `users` VALUES ('" . $_POST['username'] . "', '" . $password . "', '" . $_POST['admin'] . "')"; But every time I test it I will get an error like this: Error in query: INSERT INTO `users` VALUES ('t', 'tes', 'no'). Duplicate entry 't' for key 1What should I do about this? It is kind of annoying.. Thanks! Link to comment Share on other sites More sharing options...
Nakor Posted May 5, 2006 Share Posted May 5, 2006 I've never seen a query look like this before. Perhaps try $query2 = "INSERT INTO `users` VALUES ('$_POST[username]', '$password', '$_POST[admin]')"; It probably won't make a difference, but you can try anyways. That's the only thing I can think of first off. Link to comment Share on other sites More sharing options...
ray Posted May 5, 2006 Share Posted May 5, 2006 make sre that username is not a unique field Link to comment Share on other sites More sharing options...
reportingsjr Posted May 5, 2006 Author Share Posted May 5, 2006 I still get the same error message...Ray, what do you mean make sure it isnt a unique field? Link to comment Share on other sites More sharing options...
justsomeguy Posted May 6, 2006 Share Posted May 6, 2006 The username field is a unique field, it's the primary key. That means that it needs to be different for each record in the table. So you are getting the error because there is already a record with username "t". You need to search the database before you insert that. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now