I'm trying to insert a data in the child Table which is Activities table? This is my Query:
$Logged_In = "INSERT INTO Activities(Activity_IP,Activity_Description,Activity_By_User,Activity_Date,Activity_Time,Activity_Country)
VALUES('$User_IP2', 'Account Successfully logged-in', '$SQL_Researcher_ID', 'NOW()', '$Time', '$User_Country')";
The error shows here:
$Activity_Query = mysqli_query($Connection, $Logged_In) or die ("Could not insert data to Activities table because: ".mysqli_error($Connection));
The result should be the query will be successfully inserted into the child table which is the Activities table.
But i got this error in MySQL:
Could not insert data to Activities table because: Cannot add or update a child row: a foreign key constraint fails (
u528570277_sys
.Activities
, CONSTRAINTActivities_ibfk_1
FOREIGN KEY (Activity_By_User
) REFERENCESUser
(User_ID
) ON DELETE CASCADE ON UPDATE CASCADE)
P.S. The parent table is User table and the column referenced by the child table Activities is the User_ID column (which is the primary key of the User parent table.
Aucun commentaire:
Enregistrer un commentaire