Guest User

Untitled

a guest
Feb 8th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. <?php
  2.  
  3. class Database
  4. {
  5. protected $db_host = "localhost";
  6. protected $db_user = "root2"; //здесь специально произведена ошибка. Верное выражение - root в данном случае.
  7. protected $db_pass = "1111";
  8. protected $db_name = "program";
  9. protected $mysqli;
  10.  
  11.  
  12. public function connect()
  13. {
  14. try
  15. {
  16. $this->mysqli = new mysqli($this->db_host, $this->db_user, $this->db_pass, $this->db_name);
  17. }
  18. catch(Exception $expection)
  19. {
  20. echo 'Connection error: ' . $expection->getMessage();
  21. }
  22. }
  23.  
  24. }
  25.  
  26. $database = new Database;
  27. $database->connect();
  28. ?>
  29.  
  30. if ($this->mysqli->connect_errno) {
  31.  
  32. mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
Add Comment
Please, Sign In to add comment