Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Giulio Simeone
July 5, 2007, 11:19 am
rate this thread
when I try to insert a new record in a certain table I get the error
Cannot add or update a child row: a foreign key constraint fails
The table has three foreign keys and six other fields, but this error
appairs with every record I try to insert in the table, even if I
don't give any values to the foreign keys.
What can be the problem?
Thank you in advance!
Re: Foreign keys
This is a database question, not PHP, so ask in a database group.
That being said: in MySQL it's only possible to leave a foreign key
'empty' when using NULL, no other values allowed. So the field has to
allow NULL values, and NULL is not the same as 0 or an empty string.