Advertisement
Guest User

log

a guest
Feb 17th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "passed";
  6. $db_name = "dreport";
  7.  
  8. //create connection
  9. $conn = new mysqli($servername, $username, $password, $db_name);
  10.  
  11. //check the connection
  12. if ($conn->connect_error) {
  13.     die("Connection failed: " . $conn->connect_error);
  14. }
  15.  
  16. if (!(isset($_GET['deviceid']) && isset($_GET['rss']) && isset($_GET['lat']) && isset($_GET['long']) && isset($_GET['type']))){
  17.     echo "parameters not given properly";
  18.     print "parameters donot confirm";
  19. }
  20. /*
  21. $sql = "INSERT INTO reportings (deviceid, rss, lat, long, type) VALUES (" . $_GET['deviceid'] .",". $_GET['rss'] .",". $_GET['lat'] .",". $_GET['long']. ",". $_GET['type']. ")";
  22. */
  23. $sql = "INSERT INTO reportings (deviceid, rss, lat, `lon`, `type`) VALUES (123, 470.77, 70.33, 130.45, 34)";
  24.  
  25. if ($conn->query($sql) === TRUE) {
  26.     echo " record created successfully";
  27. } else {
  28.     echo "Error";
  29.     echo "Error: " . $sql . "<br>" . $conn->error;
  30. }
  31.  
  32. $conn->close();
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement