mansi_singhal2

value.php

Jul 24th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. ####### Code for values.php
  2.  
  3. <?php
  4.  $host = "localhost";
  5.      $db_name = "test";
  6.      $username = "root";
  7.      $password = "";
  8.      $con = mysqli_connect($host,$username,$password,$db_name);
  9.         $reading= $_GET['id'];//getting the sensor value and storing it in $reading variable
  10.      $sql="INSERT INTO `gayzer`(`ID`, `DATE`, `TIME`,`READING`) VALUES ('',NOW(),NOW(),$reading)";// NOW() function is in MySQL returns the current date and time accoring to the column specification.this is a MySQL query.
  11.      if ($con->query($sql) === TRUE) // if the current query is correctly written execute it and $con->query ($sql) executes the query and returns true if query executes successfully;
  12.      {
  13.         echo "New record created successfully";
  14.      }
  15.      else
  16.      {
  17.         echo "Error: " . $sql . "<br>" . $con->error;
  18.      }
  19. $con->close();//closing connection
  20. ?>
Add Comment
Please, Sign In to add comment