bulgaria_mitko Posted December 20, 2006 Share Posted December 20, 2006 Can u please help me? im geting this error when im trying to insert a new record into my table user:[code]ErrorSQL:INSERT INTO users( UserID, Username,PASSWORD , FirstName, LastName, EmailAddress, PostAddress, City, PhoneNumber, Admin, Allowed, UserTypeID )VALUES ('1', '***********', '123', 'xxxxxxxxx', 'yyyyyyyy', '**********@yahoo.com', 'zzzzzzzzzzz', 'hhhhhhhh', '1234567890', 'TRUE', 'TRUE', '1')MySQL replay: Documentury#1452 - Cannot add or update a child row: a foreign key constraint fails (`nimatest/users`, CONSTRAINT `users_ibfk_5` FOREIGN KEY (`UserID`) REFERENCES `reviews` (`UserID`) ON DELETE CASCADE) [/code]i have those tables:[b]reviews table:[/b]ReviewID ProductID UserID ReviewDate ReviewOnline[b]users table:[/b]UserID Username Password FirstName LastName EmailAddress PostAddress City PhoneNumber Admin Allowed UserTypeIDand [b]usertype table:[/b]UserTypeIDUserTypeand the connection between those tables are: [i]reviews->UserID REFER users->USERID ON DELETE 'nothing selected' ON UPDATE 'nothing selected'users->UserID REFER reviews->UserID ON DELETE 'CASCADE' ON UPDATE 'nothing selected'users->UserTypeID REFER usertype->UserTypeID ON DELETE 'nothing selected' ON UPDATE 'nothing selected'[/i]can u help me pls? thank you very much! Link to comment https://forums.phpfreaks.com/topic/31342-solved-error-1452-cannot-add-or-update-a-child-row-a-foreign-key-constrain/ Share on other sites More sharing options...
fenway Posted December 20, 2006 Share Posted December 20, 2006 Well, if a FK constraint fails, you know exactly where to check... its rarely wrong. Link to comment https://forums.phpfreaks.com/topic/31342-solved-error-1452-cannot-add-or-update-a-child-row-a-foreign-key-constrain/#findComment-145309 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.