Dear Gurus,
I am trying to insert information into three tables then send an email.
The purpose of the code is to place uniform orders within a company with multiple stores. Each store must be able to place orders according to job function as well as order accessories available for the job function. The example below is for the manager job function which has unique uniform requirements specific to an initial hire or promotion. I have another table that has all the accessories for all job function in the store. (because there might be an order where they need aprons for the bakers, hats for supervisors and name tags for all functions)
I also have an orders table that stores the upperlevel of order information such as order id (auto inc), store number, employee name and order date.
I can update all the tables with the following code, however I get an error that says:
Error: Duplicate entry '9' for key 1 (9 is the order id) Assuming it is because I am using the key in two separate queries.
<?php
connection info...
$date = date("Y-m-d");
$add_to_info_query = "INSERT into orders (store_no, order_date, emp_name)
VALUES ('$store_no','$date', '$emp_name')";
mysql_query($add_to_info_query);
$last_inserted_mysql_id = mysql_insert_id();
$add_to_order_query = "INSERT into cw_manager (order_id, men_pts, plus all the fields)
VALUES ($last_inserted_mysql_id, '$men_pts', etc...)";
mysql_query($add_to_order_query);
$add_to_acc_query = "INSERT into cw_acc (order_ID, m_hat, belt, belt_q)
VALUES ($last_inserted_mysql_id, '$m_hat', '$belt', '$belt_q')";
mysql_query($add_to_acc_query);
if (!mysql_query($add_to_order_query,$con))
{
die('Error: ' . mysql_error());
}
$subject = $_REQUEST['store_no'] ;
$message = $_REQUEST['emp_name'] ;
mail( "perley@burgeosands.com", "Store: $subject",
$message, "From: Career Wear Request" );
echo "Your request has been sent.";
echo "<meta HTTP-EQUIV='REFRESH' content='2; url=test_frm_menu.php' />";
mysql_close($con)
?>