I got this error while I run my PHP page in Postman. I don't know what mistake I did.
Here, I am trying to insert the id of the workordername into the ticket_raising table
.
work_order_id
is the foreign key in the ticket_raising
table.
Here is my PHP code
<?php
require 'connection.php';
$workordername = $_POST["workordername"];
$workorderid = mysqli_query($conn,"select `work_order_id` from `workorder_category` where `workorder_name` = '$workordername'");
$submitted_on = $_POST["submitted_on"];
$status = $_POST["status"];
$subject = $_POST["subject"];
$notes = $_POST["notes"];
$mysql_query = "insert into ticket_raising(work_order_id,submitted_on,status,subject,notes) values ('$workorderid','$submitted_on','$status','$subject','$notes') ";
if ($conn->query($mysql_query)==TRUE) {
echo "insert successfully";
}
else {
echo "error:".$mysql_query."<br>".$conn->error;
}
$conn->close();
?>
I am adding table schemas of ticket_raising
and workorder_category
here.
https://i.stack.imgur.com/fjg9j.png and https://i.stack.imgur.com/vsRLh.png
Any suggestive examples for inserting the foreign key into the table that would make my learning easier.