How can I connect my other table using the mysqli_insert_id? 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-&gt;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-&gt;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?
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.