How can I connect my other table using the mysqli_insert_id?
There is an error in line:

$sql = "INSERT INTO transaction_details (`edi_transaction_id`,`details`) VALUES ($edi_transaction_id,$details) ";


This should be:

$sql = "INSERT INTO transaction_details (`transaction_id`,`details`) VALUES ($edi_transaction_id,$details) ";


Finally in your code you assign the text of the command to the variable $sql, but do not execute it.