1 Reply Latest reply on Feb 6, 2012 2:15 PM by bregent

    Having problems with using Foriegn Keys in Dreamweaver cs4

    tricky72186

      I am trying to add data to multiple tables using one Form. I am getting the followin when trying to publish"

       

       

       

      Cannot add or update a child row: a Foriegn key constraint fails ('comquot_gepps1', 'authors', CONSTRAINT' authors_ibfk_1' FOREIGN KEY ('author_id') REFERENCES 'quotes' ('author_id')

       

      <form method="post" name="form1" action="<?php echo $editFormAction; ?>">

        <table align="center">

          <tr valign="baseline">

            <td nowrap align="right">Last name:</td>

            <td><input type="text" name="last_name" value="" size="32"></td>

          </tr>

          <tr valign="baseline">

            <td nowrap align="right">First name:</td>

            <td><input type="text" name="first_name" value="" size="32"></td>

          </tr>

          <tr valign="baseline">

            <td nowrap="nowrap" align="right" valign="top">Enter Quotations</td>

            <td><textarea name="quotations" cols="50" rows="5"></textarea></td>

          </tr>

            <td nowrap align="right"> </td>

            <td><input type="submit" value="Insert record"></td>

          </tr>

        </table>

        <input type="hidden" name="MM_insert" value="form1">

      </form>

      <p> </p>

        • 1. Re: Having problems with using Foriegn Keys in Dreamweaver cs4
          bregent Most Valuable Participant

          >I am getting the followin when trying to publish

           

          When trying to publish? Do you mean when submitting the form?

           

          A foreign key insert violation occurs when you try to insert a child before the parent exists. The form doesn't tell us anything. We'd need to see the SQL that is generating the insert. BTW, this has nothing to do with DW - it's a SQL problem and really belongs more in the App Dev forum.