Hi, basically, I have 3 tables; users and projects (which is a many-to-many relationship), then I have 'usersprojects' to allow the one-to-many formation. When a user adds a project, I need the project information stored and then the 'userid' and 'projectid' stored in the usersprojects table. It sounds like its really straight forward but I'm having problems with the syntax I think!?
As it stands, I have this as my INSERT queries (values going into 2 different tables):
$projectid = $_POST['projectid'];
$projectname = $_POST['projectname'];
$projectdeadline = $_POST['projectdeadline'];
$projectdetails = $_POST['projectdetails'];
$userid = $_POST['userid'];
$sql = "INSERT INTO projects (projectid, projectname, projectdeadline, projectdetails) VALUES
('{$projectid}','{$projectname}','{$projectdeadline}','{$projectdetails}')";
$result = mysql_query($sql, $connection)
or die("MySQL Error: ".mysql_error());
$sql = "INSERT INTO usersprojects (userid, projectid) VALUES
('{$userid}','{$projectid}')";
$result = mysql_query($sql, $connection)
or die("MySQL Error: ".mysql_error());
header("Location: managerhome.php");
exit();
What happens is the project information is stored all correctly, and the user ID is stored in usersprojects table, but for some reason the project ID is not being stored in usersprojects, this is now the only problem and I have looked clsely at everything, including even the field types for project ID in the usersproject table, however I cannot see anything wrong with it. Anyone have any ideas?