Foreign keys

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Giulio Simeone

    Foreign keys

    Hello,
    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!

  • Rik

    #2
    Re: Foreign keys

    On Thu, 05 Jul 2007 13:19:18 +0200, Giulio Simeone
    <viandante20005 @yahoo.itwrote:
    Hello,
    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?
    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.

    --
    Rik Wasmus

    Comment

    Working...