SHARE
TWEET

Query String to Mysql

a guest Feb 19th, 2015 228 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $servername = "localhost";
  3. $username = "username";
  4. $password = "password";
  5. $dbname = "myDB";
  6.  
  7. $now = new DateTime();
  8. parse_str( html_entity_decode( $_SERVER['QUERY_STRING']) , $out);
  9.  
  10. if ( array_key_exists( 'heap' , $out ) ) {
  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. $datenow = $now->format('Y-m-d H:i:s');
  19. $hvalue  = $out['heap'];
  20.  
  21. $sql = "INSERT INTO HeapTable ( datelog , heapvalue) VALUES ( $datenow , $hvalue )";
  22.  
  23. if ($conn->query($sql) === TRUE) {
  24.     echo "New record created successfully";
  25. } else {
  26.     echo "Error: " . $sql . "<br>" . $conn->error;
  27. }
  28.  
  29. $conn->close();
  30. }
  31. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top