Error while writing socket code for creating quiz

Viewed 29
 code: 'ER_NO_REFERENCED_ROW_2',

errno: 1452, sqlMessage: 'Cannot add or update a child row: a foreign key constraint fails (databasename.quizzes_player_1_id_links, CONSTRAINT quizzes_player_1_id_links_inv_fk FOREIGN KEY (user_id) REFERENCES up_users (id) ON DELETE CASCADE)', sqlState: '23000', index: 0, sql: 'insert into quizzes_player_1_id_links (quiz_id, user_id) values (1, 1)'

Can anyone tell me what is the error about? How to fix this?

1 Answers

The good answer is ...

You have to check if all values in column 'user_id' exist in the column 'id'.

You should have a problem on this point .... It was the problem on my side.

Related