jpergega Posted February 16, 2015 Share Posted February 16, 2015 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 More sharing options...
justsomeguy Posted February 16, 2015 Share Posted February 16, 2015 The correct solution is to make sure that your data satisfies the constraints on the table. If you don't need those constraints then you can delete the foreign keys. Link to comment Share on other sites More sharing options...
jpergega Posted February 17, 2015 Author Share Posted February 17, 2015 Thank you Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now