I've got a problem like this , I cannot get the id of the parent table .
table_name : transaction_tbl
- transaction_id
-file_name
-file_path
-description
table_name : transaction_details
-details_id
-transaction_id
- details
here is my code to insert :
$sql = "INSERT INTO transaction_tbl (`file_name`,`file_path`,`description`) VALUE('$file_name','$file_path','$description') " ;
$query = $conn->query($sql);
$transaction_id = mysqli_insert_id($conn);
if ($query === True ){
$sql = "INSERT INTO transaction_details (`transaction_id`,`details`) VALUES ($transaction_id,$details) ";
}else {
trigger_error('Wrong SQL: ' . $sql . 'Error: ' . $conn->error, E_USER_ERROR);
}
Now I can insert in my transaction_tbl but not in transaction_details. what should I do? Can somebody help me?