daily pastebin goal
84%
SHARE
TWEET

Untitled

a guest Jan 20th, 2017 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     $hostname = 'localhost';
  3.     $username = 'root';
  4.     $password = 'mypass';
  5.     $database = 'mysql';
  6.     $sql = "select * from general_log";
  7.  
  8.     //open connection to mysql db
  9.     $connection = mysqli_connect($hostname,$username,$password,$database) or die("Error " . mysqli_error($connection));
  10.  
  11.     //fetch table rows from mysql db
  12.     $result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
  13.  
  14.     //create an array
  15.     $emparray = array();
  16.     while($row =mysqli_fetch_assoc($result))
  17.     {
  18.         $emparray[] = $row;
  19.     }
  20.     echo json_encode($emparray);
  21.  
  22.     //close the db connection
  23.     mysqli_close($connection);
  24. ?>
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