Hey every one, hope all of you are fine.
please tell me when a foreign key constraints fails.
I have and error "Cannot add or update a child row: a foreign key constraint fails"
when i enter data in two tables one is user and other is user_info that is connected with user table with foreign key, but user accept data and user_info do not accept you can see it in below code i have pasted some data from .sql dump file. at the end of user table there is some insertion query but not for user_info.
Code:Table structure for table `user`
--
CREATE TABLE IF NOT EXISTS `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(30) NOT NULL,
`password` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL,
`date` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `user`
--
note:this table is accepting data.
INSERT INTO `user` (`id`, `username`, `password`, `email`, `date`) VALUES
(1, 'adnan_akbar', 'asdf', 'atta.akbar@yahoo.com', '2012-12-03 12:41:05'),
(2, 'aliahmad', 'sd', 'a2323_yad@gsdfdsf.comsd', '2012-12-03 13:02:28');
-- --------------------------------------------------------
--
-- Table structure for table `user_info`
--
CREATE TABLE IF NOT EXISTS `user_info` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`parent_id` int(11) NOT NULL,
`firstname` varchar(10) NOT NULL,
`lastname` varchar(10) NOT NULL,
`birth` int(20) NOT NULL,
`bio` varchar(160) NOT NULL,
`city` varchar(30) NOT NULL,
`country` varchar(30) NOT NULL,
`phone` int(16) NOT NULL,
`extension` int(20) NOT NULL,
PRIMARY KEY (`id`),
KEY `parent_id` (`parent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
