//the table structure i am using is.. CREATE TABLE `common_data` ( `id` int(5) NOT NULL auto_increment, `ticket_id` varchar(10) NOT NULL default '', `email` varchar(70) NOT NULL default '', `voucher_no` varchar(15) NOT NULL default '0', `voucher_date` date NOT NULL default '0000-00-00', `amount` int(5) NOT NULL default '0', `fcoord_id` int(3) NOT NULL default '0', `coord_id` int(3) NOT NULL default '0', `ttype` int(1) NOT NULL default '0', `started` tinyint(1) NOT NULL default '0', `completed` tinyint(1) NOT NULL default '0', `notes` text NOT NULL, `event` int(2) NOT NULL default '0', PRIMARY KEY (`id`), UNIQUE KEY `ticket_id` (`ticket_id`), FULLTEXT KEY `notes` (`notes`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; //query # 1 which inserts a basic row $query1=$query2="INSERT INTO `common_data`(`ttype`,`email`,`amount`,`notes`) VALUES ('1','genbummer@yahoo.com','1000','asdf')"; mysql_query($query2) or die("sorry: error with $query2 which is ".mysql_error()); //do some calculations and get a value which I need to insert as ticket_id for above inserted row $query3="UPDATE `common_data` SET `ticket_id` = '1_372245133' WHERE `id` = '1'"; mysql_query($query3) or die("sorry: error with $query3 which is ".mysql_error()); //error I keep getting for 2nd query when executed as part of a php page.. //sorry: error with UPDATE `common_data` SET `ticket_id` = '1_AF2A0AA36' WHERE `id` = '1' which is Duplicate entry '1' for key 1