TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   1062 : Duplicate entry 'xxx' for key 2 (http://www.talkphp.com/general/5577-1062-duplicate-entry-xxx-key-2-a.html)

CΛSTΞX 09-20-2010 03:17 AM

1062 : Duplicate entry 'xxx' for key 2
 
Hello,

When I try to mysql insert values with same names, it encourages this error. When I looked at the table column, I see that the row id is always "1" and it doesnt let to add same entry.



My question is, how can I add an auto increment id to that column for adding same entry names?

tony 09-20-2010 05:51 AM

If the field has an auto_increment attribute then you don't need to insert a value in that field. But using a COUNT query wouldn't return the id numbers, query your table like this (I am assuming your auto_increment query is aut_id):

SQL Code:
SELECT aut_id, aut_username FROM infolizer_authors ORDER BY aut_username;

CΛSTΞX 09-20-2010 10:16 AM

My problem is, I can't add new user if the new user's firstname (aut_username) was used before.



I can add new column for firstname, but could you please tell me how to make it that lets you add same entry names.

Village Idiot 09-20-2010 04:48 PM

Can you show us your table structure? What your telling us doesn't seem right unless you have a problem with your structure.

delayedinsanity 09-20-2010 05:16 PM

It sounds like there's a PRIMARY or UNIQUE index on that column. Since you're using phpMyAdmin, click on the link at the bottom of the Structure tab that says 'Details'. Find the one for aut_username and change it from UNIQUE to INDEX.

GUI FTW. :)

CΛSTΞX 09-20-2010 06:33 PM

Quote:

Originally Posted by delayedinsanity (Post 31001)
It sounds like there's a PRIMARY or UNIQUE index on that column. Since you're using phpMyAdmin, click on the link at the bottom of the Structure tab that says 'Details'. Find the one for aut_username and change it from UNIQUE to INDEX.

GUI FTW. :)

Thanks a lot, that works perfectly.

delayedinsanity 09-20-2010 09:43 PM

I was only just starting my second pot of coffee when I wrote that, so you'll have to forgive the oversight; normally username columns are set to UNIQUE for a reason. You don't want two users with the same username, as you might run into a plethora of conflicts, not the least of which would be signing in.


All times are GMT. The time now is 03:36 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0