Advertisement
Guest User

Jurgen Mogool

a guest
Mar 5th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 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.  
  19. $db = new DB;
  20.  
  21. $query = $db->prepare('SELECT * FROM users');
  22. $db->execute();
  23. print('Jurgen, je kan niks! Hier zijn al je users:');
  24. $results = $sth->fetchAll();
  25. print_r($results);
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement