Advertisement
Guest User

Untitled

a guest
Dec 18th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.52 KB | None | 0 0
  1. <?php
  2. $servername = "mysql.hostinger.ru";
  3. $username = "u761866288_rut";
  4. $password = "jamaica123";
  5. $dbname = "u761866288_db";
  6.  
  7.  
  8. date_default_timezone_set('Europe/Riga');
  9. $date = date('m/d/Y H:i:s');
  10.  
  11. // Create connection
  12. $conn = new mysqli($servername, $username, $password, $dbname);
  13. // Check connection
  14. if ($conn->connect_error) {
  15.     die("Connection failed: " . $conn->connect_error);
  16. }
  17.  
  18. if($_GET['i'] == "")
  19. {
  20. echo "No Data!";
  21. }
  22. else
  23. {
  24.  
  25. $t1 = htmlspecialchars($_GET["a"]);
  26. $h1 = htmlspecialchars($_GET["b"]);
  27. $wt1 = htmlspecialchars($_GET["c"]);
  28. $wd1 = htmlspecialchars($_GET["d"]);
  29. $wt2 = htmlspecialchars($_GET["e"]);
  30. $wd2 = htmlspecialchars($_GET["f"]);
  31. $ph = htmlspecialchars($_GET["g"]);
  32. $ppm = htmlspecialchars($_GET["h"]);
  33. $light = htmlspecialchars($_GET["i"]);
  34. $fan1 = htmlspecialchars($_GET["j"]);
  35. $ram = htmlspecialchars($_GET["k"]);
  36.  
  37.  
  38.  
  39. $sql = "INSERT INTO data (time, temp1, humi1, wt, wd, wt2, wd2, ph, ppm, light, fan1, ram)
  40. VALUES ('$date', '$t1', '$h1', '$wt1', '$wd1', '$wt2', '$wd2', '$ph', '$ppm', '$light', '$fan1', '$ram')";
  41.  
  42. $result = $mysqli->query('SELECT `tmax`, `thigh`, `tnorm`, `tmin` FROM ard_settings ORDER BY `id` DESC LIMIT 1');
  43. if ($result->num_rows > 0) {
  44.     // output data of each row
  45.     while($row = $result->fetch_assoc()) {
  46.  
  47.     echo "Error: " . $sql . "<br>" .;
  48. }
  49.  
  50.  
  51. if ($conn->query($sql) === TRUE) {
  52.  
  53.  
  54.  
  55.  
  56. } else {
  57.     echo "" . $row["tmax"]. "," . $row["thigh"]. "," . $row["tnorm"]. "," . $row["tmin"]. ""
  58. }
  59. $result->close();
  60. $conn->close();
  61.  
  62. }
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement