I was trying to insert a value on my MySQL database table when it failed and gave me the following error:
#1452 - Cannot add or update a child row: a foreign key constraint fails
There is nothing wrong with my syntax nor with the SQL query string that I am trying to push on the table. So what could be wrong?
One problem to take note is that the error log tells something abou the foreign key. The issue arises when I am trying to insert (also happens during delete process) a record that uses a foreign key that is NOT at any case existing on the database any more.
This error logs are usually followed by an element that causes for it to be triggered. By looking at the table from where the said foreign key comes, you may check if the said value really do exists.