I am working with mysql in my project and when I try to call the webAPI to insert data to the database, it inserts an empty row before the inserted row.
Can anyone help please?
$rest_json = file_get_contents("php://input");
$_POST = json_decode($rest_json, true);
$nom = $_POST['nom'];
$query = "INSERT into class (nom_class) values('$nom')";
$result = $db->query($query);
if ($result === TRUE) {
$res = "Inserted" . $nom;
echo json_encode($res);
} else {
echo json_encode("Error" . $query . "<br>" . $db->error);
}
break;
I have tried EMPTY, and ISSET features but it didn't work.
This is the database:
I'll be so grateful if any one could help.