title: A foreign key constraint fails
body: <p>I am relatively new in php and mysql.The problem that i am facing while i inserting value in my <code>leave</code> table.My <code>leave</code> table containing following  column..</p>
  
  <p>1.lid(INT primary key)</p>
  
  <p>2.empname(varchar)</p>
  
  <p>3.username(varchar)</p>
  
  <p>4.nod(INT)</p>
  
  <p>5.sdate(DATE)</p>
  
  <p>6.edate(DATE)</p>
  
  <p>7.reason(varchar) </p>
  
  <p>8.action(varchar)</p>
  
  <p>9.empID (INT FOREIGN KEY) </p>
  
  <p>here <code>empID</code> is the <code>foreign key</code> references from <code>users</code> table. The problem that im facing while inserting values into the <code>leave</code> table.ERROR is given below</p>
  
  <p><strong>Cannot add or update a child row: a foreign key constraint fails (<code>db_attendance1</code>.<code>leave</code>, CONSTRAINT <code>leave_ibfk_1</code> FOREIGN KEY (<code>empID</code>) REFERENCES <code>users</code> (<code>empID</code>))</strong></p>
  
  <p>here i just send  the query and here it is..</p>
  
  <pre><code>    mysql_query("INSERT INTO `leave` 
             (`empname`, `username`,
              `nod`, `sdate`, `edate`,
              `reason`,`action`) 
              VALUES ('$empname', '$username', 
              '$nod', '$sdate', 
              '$edate', '$reason','');",
              $dbCon) or die(mysql_error());
  </code></pre>