Rodney,
You have been a great help and I think I got in a little over my head because I tried to write an over-zealous code. I had all the code working to put in the guest and the alumni data but not the data into the alumnus_to_guest table (I called this rsvp_list). Right now my code is below. I have a form setup to put the data in and I don't know enough about PHP to script in advanced features so I am put in four different guest fields so that you can add up to four guests and then tried writing if statements to try and say whether data was inputted into the guest lines. When I try to parse this code I get the error that says duplicate was made can you help me troubleshoot this code:
//Set variables for database and table
$table_alumni = "alumni";
$table_guest = "guest";
$table_rsvp = "rsvp_list";
//SQL to insert alumni info into database
mysql_select_db('chemdata') or exit(mysql_error());
$sql = "INSERT INTO $table_alumni SET lastname='$POST[lastname]', firstname='$POST[firstname]', mi='$POST[mi]', advisor='$POST[advisor]',
email='$POST[email]', year_grad='$POST[year]', degree='$POST[degree]', rsvp='$POST[attend]'";
$result = @($sql, $connection) or die(mysql_error());
$pid = mysql_insert_id();
mysql_close();
//if statements to determine if alumni entered a guest and insert guest into guest table as well as guest and alumni into rsvp table
if ($POST[glast] != "") {
include "mysql_connect_snacks.php";
mysql_select_db('chemdata') or exit(mysql_error());
$sql2 = "INSERT INTO $table_guest SET glastname='$POST[glast]', gfirstname='$POST[gfirst]', relation='$POST[relation]', pid='$pid'";
$result2 = @($sql2, $connection) or die(mysql_error());
$gid1 = mysql_insert_id();
$sql6 = "INSERT INTO $table_rsvp SET eid='1', pid='$pid', gid='$gid1'";
$result6 = @($sql6, $connection) or die(mysql_error());
mysql_close;
}
if ($POST[glast2] != "") {
include "mysql_connect_snacks.php";
mysql_select_db('chemdata') or exit(mysql_error());
$sql3 = "INSERT INTO $table_guest SET glastname='$POST[glast2]', gfirstname='$POST[gfirst2]', relation='$POST[relation2]', pid='$pid'";
$result3 = @($sql3, $connection) or die(mysql_error());
$gid2 = mysql_insert_id();
$sql7 = "INSERT INTO $table_rsvp SET eid='1', pid='$pid', gid='$gid2'";
$result8 = @($sql7, $connection) or die(mysql_error());
mysql_close;
}
if ($POST[glast3] != "") {
include "mysql_connect_snacks.php";
mysql_select_db('chemdata') or exit(mysql_error());
$sql4 = "INSERT INTO $table_guest SET glastname='$POST[glast3]', gfirstname='$POST[gfirst3]', relation='$POST[relation3]', pid='$pid'";
$result4 = @($sql4, $connection) or die(mysql_error());
$gid3 = mysql_insert_id();
$sql8 = "INSERT INTO $table_rsvp SET eid='1', pid='$pid', gid='$gid3'";
$result8 = @($sql8, $connection) or die(mysql_error());
mysql_close;
}
if ($POST[glast4] != "") {
include "mysql_connect_snacks.php";
mysql_select_db('chemdata') or exit(mysql_error());
$sql5 = "INSERT INTO $table_guest SET glastname='$POST[glast4]', gfirstname='$POST[gfirst4]', relation='$POST[relation4]', pid='$pid'";
$result5 = @($sql5, $connection) or die(mysql_error());
$gid4 = mysql_insert_id();
$sql9 = "INSERT INTO $table_rsvp SET eid='1', pid='$pid', gid='$gid4'";
$result9 = @($sql9, $connection) or die(mysql_error());
mysql_close;
}