I’m having trouble selecting the “decoded_payload” part of the JSON file. I don’t think I’m referencing the right section of the code, as the reading doesn’t end up in my database.
<?php
$data = file_get_contents("php://input");
$json = json_decode($data, true);
$decoded_payload = $json['decoded_payload'];
$temp = $end_device_ids['temp'];
$servername = "";
$username = "";
$password = "";
$dbname = "";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO tbl_temp (temp)
VALUES ('$temp')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . " => " . $conn->error;
}
$conn->close();
?>