I've finally succeeded, at least for the moment, in setting up the registration and login scripts for my proposed membership site. Now I'd like to enable potential members to enter some data, using a form that is provided.
My database has two tables -- users and entries. In the users table, each user has a user_id.
My question is - how do I link the correct user_id (in the users table) to that user's data (in the entries table)? Right now, there is no link at all!
It seems like there must be some very obvious answer to this question, but so far I haven't been able to find it. 😕
Please help! :queasy:
ETA: Tables are linked by keys, right? So I tried using keys, but that has not worked.
Initially, I was using MyISAM tables, in phpMyAdmin. MyISAM doesn't support foreign keys. phpMyAdmin offers primary, unique, and index keys - but which one of those would I use??
So I switched to InnoDB tables, thinking that I would use a foreign key. I think I set it up correctly, so that user_id, the primary key in the users table, is a foreign key in the entries table.
However, all I have gotten for my trouble is an error message --
Could not add the entry because:
Cannot add or update a child row: a foreign key constraint fails (/entries, CONSTRAINT entries_ibfk_1 FOREIGN KEY (user_id) REFERENCES users (user_id)).
Does anyone know what that means, and how to correct it?
Please help, if you can. Earlier this week it looked like I was making progress, but now it feels like the same old obstacle course. 🙁