Advertisement
Guest User

returns null

a guest
Feb 3rd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. <?php
  2. class Connection {
  3.  
  4. protected $host = "localhost";
  5. protected $dbname = "aaron_aaron";
  6. protected $user = "aaron_aaron";
  7. protected $pass = "d6G4X5S54";
  8. protected $DBH;
  9.  
  10. function __construct()
  11. {
  12. try {
  13. $this->DBH = new PDO("mysql:host=$this->host;dbname=$this->dbname", $this->user, $this->pass);
  14. }
  15. catch (PDOException $e)
  16. {
  17. echo $e->getMessage();
  18. }
  19. }
  20. public function getMembers()
  21. {
  22. $sth = $dbh->prepare("SELECT * FROM members");
  23. $sth->execute();
  24. $result = $sth->fetchAll();
  25. }
  26. }
  27.  
  28. $dbh = new Connection($host,$dbname,$user,$pass);
  29.  
  30. var_dump($result);
  31.  
  32.  
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement