title: How to insert in multiple table connected by foreign key, at same event
body: <p>I have two tables:</p>
  
  <p><code>candidate_register_table</code> with the following schema:</p>
  
  <pre><code>|----------------------------------------------------|
  |   username  |  name   |  age   | sex   | password  |
  |----------------------------------------------------|
  </code></pre>
  
  <p><code>candidate_social_table</code> with the following schema</p>
  
  <pre><code>|--------------------------------------------------------|
  |   username  |  religion   | caste  | address   | city  |
  |--------------------------------------------------------|
  </code></pre>
  
  <p>In both tables, <code>username</code> are primary keys in their corresponding table.</p>
  
  <p>I want to insert data in both the table in a single click event, where the username in table <code>candidate_register_table</code> is a foreign key in <code>candidate_social_table</code> also</p>
  
  <p>This is my reg_conn.php where the data are getting inserted:</p>
  
  <pre><code>&lt;?php
  include('connection.php')'
  
  $sql_register="INSERT INTO candidate_register_table (username, name, age, sex, password) )           VALUES('$_POST[username]','$_POST[name]','$_POST[age]', '$_POST[sex]','$_POST[password]')";
  $sql_social_disable="ALTER TABLE candidate_social_table disable CONSTRAINT fk_candidate_register_table";
  $sql_social="INSERT INTO candidate_social_table (username) VALUES('$_POST[username]')";
  $sql_social_enable="ALTER TABLE candidate_social_table enable CONSTRAINT fk_candidate_register_table";
  
  if(mysql_query($sql_register,$con) &amp;&amp; mysql_query($sql_social_disable,$con) &amp;&amp; mysql_query($sql_social,$con)  &amp;&amp; mysql_query($sql_social_enable,$con))
     { echo "you have been registered";
     }
  else
     {
         die('Error: ' . mysql_error());
         echo "Something went wrong. Might be a Fatal Error";
     }
  ?&gt;
  </code></pre>
  
  <p>Now the problem is that, my connection and all others are all working perfectly, but the query: </p>
  
  <pre><code>ALTER TABLE candidate_social_table disable CONSTRAINT fk_candidate_register_table`
  </code></pre>
  
  <p>Is not getting executed, its throwing the following error:</p>
  
  <pre><code>Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT fk_t1' at line 1
  </code></pre>