I have two tables that am trying to link, a User table and Registration table:
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL auto_increment,
`first_name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(32) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=19 ;
CREATE TABLE IF NOT EXISTS `registration` (
`userid` int(11) NOT NULL,
`sex` varchar(10) NOT NULL,
`dob` date NOT NULL,
`location` varchar(30) NOT NULL,
`edu_level` varchar(32) NOT NULL,
`work` varchar(30) NOT NULL,
`rel_status` varchar(10) NOT NULL,
KEY `userid` (`userid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
And I created a link between them with the design tab in phpadmin, but when am inserting records into the registration table, it keeps saying this:
Cannot add or update a child row: a foreign key constraint fails
(`letzfuze/registration`, CONSTRAINT `registration_ibfk_1` FOREIGN KEY (`userid`) REFERENCES `users` (`id`))
Please who can help?