I have some issues regarding data upI get this error:
Error: INSERT INTO TEMPERATURE (time, temperature) VALUES (1969-12-31 19:00:00, ) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '19:00:00, )' at line 2
This is the code I am using:
<?php
//GET data from the module
$time = $_GET["time"] ;
$temperature = $_GET["temperature"] ;
//Change the time atributes
$time = date("Y-m-d H:i:s", strtotime($time-30000));
//MySQL data
$servername = "host.com";
$username = "admin";
$password = "password";
$dbname = "mobile";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Append data
$sql = "INSERT INTO GPS (time, temperature)
VALUES ($time, $temperature)";
// Check
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
Where the "GET" temperature has the following format: YYYYmmddHHMMSS in UTC and I want to display UTC-3 (that is why I subtract 30 000).