This topic is locked
[SOLVED]

 error msg

7/19/2006 3:24:42 PM
PHPRunner General questions
A
amirgulamali author

i am trying to add an entry into another table using:

function BeforeAdd(&$values)

{
// Parameters:

// $values - Array object.

// Each field on the Add form represented as 'Field name'-'Field value' pair
//********** Save new data in another table ************

global $conn,$strTableName;
$strSQLSave = "INSERT INTO _1ee0 (fname, lname, student_no, email) values (";
$strSQLSave .= $values["fname"].",";

$strSQLSave .= $values["lname"].",";

$strSQLSave .= $values["student_no"].",";

$strSQLSave .= $values["email"];
$strSQLSave .= ")";

db_exec($strSQLSave,$conn);
return true;
// return true if you like to proceed with adding new record

// return false in other case
}


when i enter any value for student_no

i am getting the following error:
Cannot add or update a child row: a foreign key constraint fails (`test/_1ee0`, CONSTRAINT `student_no` FOREIGN KEY (`student_no`) REFERENCES `_students` (`student_no`) ON DELETE CASCADE ON UPDATE CASCADE)
Why is that? any solution? my tables have parent-child relationships

Alexey admin 7/20/2006

Amir,
the values you enter into student_no field should match student_no field of students table.

Either enter correct values or remove the foreign key constraint from your database.