TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-20-2010, 03:17 AM   #1 (permalink)
The Acquainted
 
Join Date: Feb 2008
Posts: 107
Thanks: 3
CΛSTΞX is on a distinguished road
Default 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?
__________________
Downloadic
infolizer
Send a message via MSN to CΛSTΞX
CΛSTΞX is offline  
Reply With Quote
Old 09-20-2010, 05:51 AM   #2 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

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;
tony is offline  
Reply With Quote
Old 09-20-2010, 10:16 AM   #3 (permalink)
The Acquainted
 
Join Date: Feb 2008
Posts: 107
Thanks: 3
CΛSTΞX is on a distinguished road
Default

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.
__________________
Downloadic
infolizer
Send a message via MSN to CΛSTΞX
CΛSTΞX is offline  
Reply With Quote
Old 09-20-2010, 04:48 PM   #4 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

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

Village Idiot is offline  
Reply With Quote
Old 09-20-2010, 05:16 PM   #5 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

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. :)
__________________
uʍop ǝpısdn sı ɹǝʇndɯoɔ ɹnoʎ sıɥʇ pɐǝɹ uɐɔ noʎ ɟı
delayedinsanity is offline  
Reply With Quote
Old 09-20-2010, 06:33 PM   #6 (permalink)
The Acquainted
 
Join Date: Feb 2008
Posts: 107
Thanks: 3
CΛSTΞX is on a distinguished road
Default

Quote:
Originally Posted by delayedinsanity View Post
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.
__________________
Downloadic
infolizer

Last edited by CΛSTΞX : 09-20-2010 at 07:13 PM.
Send a message via MSN to CΛSTΞX
CΛSTΞX is offline  
Reply With Quote
Old 09-20-2010, 09:43 PM   #7 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

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.
__________________
uʍop ǝpısdn sı ɹǝʇndɯoɔ ɹnoʎ sıɥʇ pɐǝɹ uɐɔ noʎ ɟı
delayedinsanity is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
If duplicate title, add rand else, do nothing?? marxx General 3 02-17-2010 10:12 PM


All times are GMT. The time now is 02:57 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design