Cannot add or update a child row: a foreign key constraint fails from php and mysql -


i working php file giving input database. , database giving following error

cannot add or update child row: foreign key constraint fails (`amaradmission`.`login`, constraint `fk_login_students1` foreign key (`students_idstudents`) references `students` (`idstudents`) on delete no action on update no action) 

here php file:

<?php   header('cache-control: no-cache, must-revalidate');   header('expires: mon, 01 jan 2016 00:00:00 gmt');   header('content-type: application/json');   $host='localhost';   $user='root';   $pass='';   $con=mysql_connect("localhost","root","");   mysql_select_db("amaradmission",$con);   $passingyear = $_get['passingyear'];   $board= $_get['board'];   $gpa = $_get['gpa'];   $group = $_get['group'];     //$data = array($passingyear, $board,$gpa, $group);     //echo json_encode($data);    $query="insert hsc(board,passing_year,gpa,hsc_group) values('$board','$passingyear','$gpa','$group');";    if(mysql_query($query))   {      echo "i here";   }else{    echo  mysql_error();   }   //}    ?> 

screen shot of table problem exists screen shot of parent table parent table of previous table mysql workbench structure image mysql workbench structure

php file in server side. server receiving information using js file. php file getting correct value unable insert in database due foreign key issue. don't have idea how solve problem. have added image of db structure well. added mysql workbench structure , parent table screen shot. confused on how insert data when foreign key exist in table.

thank you.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -