What does the following mean: "Duplicate entry '' for key 'username'"
I don't have any fields called 'username'. I used to but then I deleted it.
I don't have any fields called 'username'. I used to but then I deleted it.
Debug Data
Unique ID [GH]
Unique ID: TH3532A
Tablechronoforms_data_StaffList: :store failed
Duplicate entry '' for key 'username' SQL=INSERT INTO `jb823_chronoforms_data_StaffList` (`cf_ipaddress`,`uniqueid`,`title`,`surname`,`initials`,`subjects`,`management`) VALUES ('x.x.x.x','TH3532A','Mr','Barry',' M','English','Dean (Yr 12)')
Hi rcadmin,
This could happen if 'username' is set up as a primary key for the table. I recall some odd errors when the primary key value is zero. You might need to remove the column from the table if it's no longer in use.
Bob
This could happen if 'username' is set up as a primary key for the table. I recall some odd errors when the primary key value is zero. You might need to remove the column from the table if it's no longer in use.
Bob
Yes that is what I thought but no such column exists.
[attachment=0]MySQL.png[/attachment]
Next step will be to delete the table and recreate it 😲
[attachment=0]MySQL.png[/attachment]
Next step will be to delete the table and recreate it 😲
Hi rcadmin,
Hmmm . . . weird - I wonder if it was left in the table setting as an index??? But delete and re-create sounds good to me.
Bob
Hmmm . . . weird - I wonder if it was left in the table setting as an index??? But delete and re-create sounds good to me.
Bob
Ok, found the one problem. I exported by table and found the following:
email used to be username and when I renamed it the unique entry was not changed. I deleted the table and imported the data, changing the UNIQUE entry to UNIQUE KEY `email` (`email`)
I am still getting the error but the issue is no longer the database. When I update and entry the database thinks I am adding a duplicate entry for the email. Do I need to remove the unique parameter or what am I doing wrong? 😶
CREATE TABLE IF NOT EXISTS `jb823_chronoforms_data_StaffList` (
`cf_id` int(11) NOT NULL AUTO_INCREMENT,
`cf_modified` datetime NOT NULL,
`cf_ipaddress` varchar(255) CHARACTER SET latin1 NOT NULL,
`uniqueid` varchar(255) NOT NULL,
`email` varchar(255) CHARACTER SET latin1 NOT NULL,
`title` varchar(255) CHARACTER SET latin1 NOT NULL,
`surname` varchar(255) CHARACTER SET latin1 NOT NULL,
`initials` varchar(255) CHARACTER SET latin1 NOT NULL,
`subjects` varchar(255) CHARACTER SET latin1 NOT NULL,
`management` varchar(255) CHARACTER SET latin1 NOT NULL,
PRIMARY KEY (`cf_id`),
UNIQUE KEY `username` (`email`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=86 ;
email used to be username and when I renamed it the unique entry was not changed. I deleted the table and imported the data, changing the UNIQUE entry to UNIQUE KEY `email` (`email`)
I am still getting the error but the issue is no longer the database. When I update and entry the database thinks I am adding a duplicate entry for the email. Do I need to remove the unique parameter or what am I doing wrong? 😶
Hi rcadmin,
I think that I'd remove the Unique Key setting if that is causing problems. You can do a separate query to check uniqueness of the email if you need it.
Bob
I think that I'd remove the Unique Key setting if that is causing problems. You can do a separate query to check uniqueness of the email if you need it.
Bob
Done... just for those who might want to do this sometime:
What is happening now is that every time I edit the record it creates a new-duplicate entry. I will PM you the link so that you can take a look and see what I mean (if you can time that is :-) .
ALTER TABLE jb823_chronoforms_data_StaffList DROP INDEX email
What is happening now is that every time I edit the record it creates a new-duplicate entry. I will PM you the link so that you can take a look and see what I mean (if you can time that is :-) .
I thought the issue might be in the copy of my custom listing:
So I changed <a href="index.php?option=com_chronoforms&chronoform=StaffList&id={cf_id}">{surname}</a> to <a href="index.php?option=com_chronoforms&chronoform=StaffList&task=cc_edit_data&id={cf_id}">{surname}</a>
But that did not appear to make any difference
<tr>
<td>{title}</td>
<td><a href="index.php?option=com_chronoforms&chronoform=StaffList&id={cf_id}">{surname}</a></td>
<td>{subjects}</td>
<td>{management}</td>
</tr>
So I changed <a href="index.php?option=com_chronoforms&chronoform=StaffList&id={cf_id}">{surname}</a> to <a href="index.php?option=com_chronoforms&chronoform=StaffList&task=cc_edit_data&id={cf_id}">{surname}</a>
But that did not appear to make any difference
Hi rcadmin,
Have you tried &cf_id={cf_id}
Otherwise you will need to copy the value in a Custom Code action:
You need to have the id of the record you are updating set in the $form->data array before the save; otherwise a new record will be created.
Bob
Have you tried &cf_id={cf_id}
Otherwise you will need to copy the value in a Custom Code action:
<?php
$form->data['cf_id'] = $form->data['id'];
?>
You need to have the id of the record you are updating set in the $form->data array before the save; otherwise a new record will be created.
Bob
This topic is locked and no more replies can be posted.