...

View Full Version : whats this error about ??



PHPycho
04-01-2007, 09:11 AM
Hello forums!!
I tried to insert following query in the table called user_table

INSERT INTO user_table (id,username,realname,email,password,date_created)
VALUES
('','user1','user name','user1@localhost','1a1dc91c907325c69271ddf0c944bc72',now())
I got the following errors(in Phpmyadmin):
Error


SQL query:

INSERT INTO mantis_user_table( id, username, realname, email,
PASSWORD , date_created )
VALUES (
'', 'user1', 'user 111', 'rajen@localhost1', '1a1dc91c907325c69271ddf0c944bc72', now( )
)

MySQL said: Documentation
#1062 - Duplicate entry '' for key 2

My table structure is:

CREATE TABLE `user_table` (
`id` int(10) unsigned NOT NULL auto_increment,
`username` varchar(32) collate latin1_general_ci NOT NULL default '',
`realname` varchar(64) collate latin1_general_ci NOT NULL default '',
`email` varchar(64) collate latin1_general_ci NOT NULL default '',
`password` varchar(32) collate latin1_general_ci NOT NULL default '',
`date_created` datetime NOT NULL default '1970-01-01 00:00:01',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_user_cookie_string` (`cookie_string`),
UNIQUE KEY `idx_user_username` (`username`),
KEY `idx_enable` (`enabled`),
KEY `idx_access` (`access_level`)
);

I am unable to figure out the problems
Please help!!
Thanks in advance to all of you.

guelphdad
04-01-2007, 02:58 PM
two things. number one, leave your auto increment column out of the insert entirely, don't name that column and don't insert a value into it.

second the key 2 means your second column, so you are trying to insert a value that already exists there when you have defined a unique key on that column.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum