title: php / sql - correctly read and insert data
body: <p>I have some issues regarding data upI get this error:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>This is the code I am using:</p>
  
  <pre><code>&lt;?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-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  }
  
  // Append data
  $sql = "INSERT INTO GPS (time, temperature)
  VALUES ($time, $temperature)";
  
  // Check
  if ($conn-&gt;query($sql) === TRUE) {
      echo "New record created successfully";
  } else {
      echo "Error: " . $sql . "&lt;br&gt;" . $conn-&gt;error;
  }
  
  $conn-&gt;close();
  ?&gt;
  </code></pre>
  
  <p>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).</p>
  
  <p><a href="https://i.stack.imgur.com/St3QZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/St3QZ.jpg" alt="This is the SQL table"></a></p>