How can I connect my other table using the mysqli_insert_id?
0
votes
1
answer
114
views
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?
Asked by aiai
(103 rep)
Jun 25, 2015, 07:53 AM
Last activity: Dec 19, 2021, 08:04 PM
Last activity: Dec 19, 2021, 08:04 PM