Jump to content

[SOLVED] Error #1452 - Cannot add or update a child row: a foreign key constrain


bulgaria_mitko

Recommended Posts

Can u please help me? im geting this error when im trying to insert a new record into my table user:

[code]Error

SQL:

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
Review
Online

[b]users table:[/b]

UserID 
Username
Password
FirstName
LastName
EmailAddress
PostAddress
City
PhoneNumber
Admin
Allowed
UserTypeID

and [b]usertype table:[/b]

UserTypeID
UserType


and 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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.