Friday, 30 September 2011

Error Code : 1062 Duplicate entry '' for key 1 auto_increment [SOLVED]

I am using mySQL and Fabrik and Joomla for my web app and out of the blue it started giving errors:
Duplicate entry '' for key 1 SQL=INSERT INTO `main_table` (`field1`,`field2`,`field3`) VALUES ( 'Value1','Value2','','Value3') 
This meant that no data was being successfully entered into that database table :(


After Googling a bit (no, a lot) I stumbled into this blog which helped me a lot (thanks Vinu Thomas):

The important sentences:  “Mysql throws this error because the field type of the auto increment field is not large enough to hold the next value, so it tries to wraps the count back to ’0′ where the is already a record with that value.
We changed the field from int to unsigned bigint which fixed the problem for us. So if you face the same problem, check if your auto-increment field has maxed the datatype for that field.

That’s exactly what I did and saw that my table definition was this – where field1 was the PK and of type varchar(255):
table_name CREATE TABLE `table_name` (
`field1` varchar(255) NOT NULL auto_increment,
`field2` varchar(15) default NULL,
`field3` varchar(255) default NULL,

I altered the table to this and the problem was solved!:
table_name CREATE TABLE `table_name` (
`field1` bigint(255) unsigned NOT NULL auto_increment,                      
`field2` varchar(15) default NULL,                                             
`field3` varchar(255) default NULL,                                          

Using this sql statement:
alter table `dbname`.`table_name` change `field1` `field1` bigint(255) UNSIGNED NOT NULL AUTO_INCREMENT

Sunday, 25 September 2011

Tree fell across Doordrift Road, Constantia in Cape Town

A colleague’s friend told of a story that she was driving on Doordrift Road last night (Saturday) and about 21h00 (after sunset – so it was already quite dark) when they heard a load creaking sound then suddenly this HUGE tree fell about 20m in front of their car (which was travelling at about 60km/h).

They got the fright of their lives and luckily they managed to stop in time – they also were sooo, lucky that the tree didn’t fall on top of their car!

This is what they saw last night:


They got out and tried to manage the traffic as best as they could – including cyclists who couldn’t see the tree across the road.

They notified ADT (security company) and the local authorities who managed to close the road and start working on clearing the tree.

This morning we decided to go and see if the tree was cleared. I was very surprised to see that the road was still closed and the chain saw was still hard at work to removed the HUGE tree.

Here are some photos of what we saw this morning:
Cape Town-20110925-00025  Cape Town-20110925-00027 Cape Town-20110925-00028  Cape Town-20110925-00030 Cape Town-20110925-00031 Cape Town-20110925-00032   Cape Town-20110925-00034

This is the damage to the townhouses across the road:

Cape Town-20110925-00036  IMG-20110925-00035

So, now, who pays for the clearing of the tree and for the damage to the wall, wrought iron fence and electric fence?

Seems like the construction workers “trimmed” the roots of the tree.  These construction workers were building a pathway along the road and dug quite deeply to lay the foundations for this cobble pathway.

Oh well – at least nobody got killed and we will need to see who wins the fight for these material items.  Those people in the car were really lucky it didn’t land on them! 

Live Traffic Feed


Be notified of
page updates
it's private
powered by

Copyright © 2008 HandyTechTipper. All articles are released under the Creative Commons Attribution 2.5 South Africa license, unless where otherwise stated.