Advertisement
Guest User

Untitled

a guest
Feb 20th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <?php
  2. require('dblog.php');
  3.  
  4. //Open PDO Connection
  5. $dbconfig = array(
  6. 'user' => $username,
  7. 'pass' => $password,
  8. 'host' => 'localhost',
  9. 'name' => $dbname,
  10. );
  11.  
  12. //connect
  13. $conn = new PDO("mysql:host=$dbconfig[host];dbname=$dbconfig[name]", $dbconfig[user], $dbconfig[pass]);
  14. $conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
  15.  
  16.  
  17. $query = "SELECT * FROM Events;";
  18. $result = $conn->prepare($query);
  19. //$result->bindParam(":userId", $userId); - Use this to bind param in future!
  20. $result->execute();
  21.  
  22.  
  23. $r = $result->fetchAll();
  24. echo json_encode($r, JSON_UNESCAPED_UNICODE);
  25.  
  26.  
  27.  
  28. ?>
  29.  
  30. <?php
  31. // Connects to Our Database
  32. $server = "localhost";
  33. $username = "yourUsername";
  34. $password = "yourPassword";
  35. $dbname = "dbNAME";
  36.  
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement