I keep on receiving this error when I attempt to reply to a post on my forum system:
Cannot add or update a child row: a foreign key constraint fails ('forum'.'posts', CONSTRAINT 'posts_ibfk_2' FOREIGN KEY ('post_by') REFERENCES 'users' ('user_id')
ON UPDATE CASCADE).
I know this question might have been answered but for my DB schema I would like to get more input on where I missed something. Below is my DB schema for users and posts tables:
users table:
user_id int(8)
user_name varchar(30)
user_pass varchar(255)
user_email varchar(255)
user_date datetime
user_level int(8)
N.B. user_id
is my PK
posts table:
post_id int(8)
post_content text
post_date datetime
post_topic int(8)
post_by int(8)
N.B. post_by is the FK
which references to user_id
in the users table.
I am pretty sure my schema is not correct or something and your help will be greatly appreciated.