Advertisement
Guest User

Untitled

a guest
Apr 4th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. <?php
  2.  
  3. class sql
  4. {
  5. public $servername;
  6. public $username;
  7. public $password;
  8.  
  9. function setLogin($name, $user, $pass)
  10. {
  11. $this->servername = $name;
  12. $this->username = $user;
  13. $this->password = $pass;
  14. }
  15.  
  16. function print()
  17. {
  18. echo $this->servername;
  19. echo $this->username;
  20. echo $this-> password;
  21. }
  22.  
  23. function connect()
  24. {
  25. $conn = new mysqli($this->servername, $this->username, $this->password);
  26. // Check connection
  27. if ($conn->connect_error) {
  28. die("Connection failed: " . $conn->connect_error);
  29. }
  30. echo "Connected successfully";
  31. }
  32.  
  33. }
  34.  
  35. $mysql = new sql();
  36. $mysql->setLogin("localhost", "root", "");
  37. $mysql->connect();
  38.  
  39.  
  40. // Create connection
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement