PDA

View Full Version : #1216 - Cannot add or update a child row:


bazz
11-30-2007, 06:04 PM
Hi,


#1216 - Cannot add or update a child row: a foreign key constraint fails

Can anyone explain what this means. I have been updating this table today already with no problems

bazz

Fumigator
11-30-2007, 06:29 PM
You must be using a INNODB style database and you've placed constraints on key::foreign key relationships in a way that prevents you from changing the foreign key to a value that does not have a match in the parent table.

bazz
11-30-2007, 08:24 PM
Yes it was set up as an innoDb table because of the foreign key thing but I hadn't added any restrictions. I have added a new table, set up the same way, and it seems to work so, I am confused as to why the 'old' one stopped accepting new entries especially when it had been doing so all afternoon.

Still, looking at the optimistic side, it has made me double check set-ups as I continue to develop my MySQL capabilities. And I am now making the order of entries more compliant with an organised setup, such as all accommodation entries being clustered together so that if I have to come back through phpMyAdmin to fix things, it wil be more readable.

bazz