Jump to content

How to insert a record with 2 foreign keys into a table


jpergega

Recommended Posts

Hi,

 

I have a table contains 2 foreign keys and I am having trouble inserting a record to this table. Below is my code:

$query = "            INSERT INTO reply (			foreignKey1_id,foreignKey2_id,message,date_Created            )            VALUES (             '$foreignKey1','$foreignkey2', '$msg',NOW()            )";

This is the error message: Cannot add or update a child row: a foreign key constraint fails....................

 

I have used the disable foreign key checks but still getting this error. Is there other way to make this work?

 

Thanks

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...