Advertisement
Guest User

gr

a guest
Mar 5th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. <?php
  2. session_start();
  3. class databaseConnection {
  4. protected $db_name = "url";
  5. protected $db_user = "root";
  6. protected $db_pass = "";
  7. protected $db_host = "localhost";
  8.  
  9. public function __construct() {
  10. try {
  11. parent::__construct("mysql:host={$this->db_host};dbname={$this->db_name}", $this->db_user, $this->db_pass);
  12. } catch (PDOException $e) {
  13. echo $e->getMessage();
  14. }
  15. }
  16. }
  17.  
  18. $db = new databaseConnection();
  19.  
  20. $query = $db->prepare('SELECT * FROM users');
  21. $db->execute();
  22. print('Jurgen, je kan niks! Hier zijn al je users:');
  23. $results = $db->fetchAll();
  24. print_r($results);
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement