adrake9
asked on
Why won't my mysql_insert_id work?
Below is the final step of my form processor. I need to get the job_id (Primary Key, Auto Increment) from the last Insert and pass it into the URL in the Header: location bit.
For some reason I can't figure out why its not doing it.
I've used the mysql_insert_id() before but I'm not getting any returned value.
any help is appreciated
-a
For some reason I can't figure out why its not doing it.
I've used the mysql_insert_id() before but I'm not getting any returned value.
any help is appreciated
-a
//---------INSERT-----------//
// Set up the SQL query and get it ready for input
$sql = "INSERT INTO timecard_data
(emp_id, prop_id, unit_id, work_type, job_duration, job_notes, job_charge, job_date)
VALUES
('$emp_id', '$prop_id', '$unit_id', '$work_type', '$job_duration', '$job_notes', '$job_charge', '$job_date')";
// make the actual input into the database
mysql_query($sql,$conn) or die(mysql_error());
mysql_close($conn);
//---------ADD. ACTIONS-----------//
// redirect the user to back to his "dashboard" using the emp_id variable
$id = mysql_insert_id();
$url = ("emp-timecard.php?emp_id=" . $emp_id . "&job_id=" . $id);
header("Location: $url");
exit();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER