Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class sql
- {
- public $servername;
- public $username;
- public $password;
- function setLogin($name, $user, $pass)
- {
- $this->servername = $name;
- $this->username = $user;
- $this->password = $pass;
- }
- function print()
- {
- echo $this->servername;
- echo $this->username;
- echo $this-> password;
- }
- function connect()
- {
- $conn = new mysqli($this->servername, $this->username, $this->password);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- echo "Connected successfully";
- }
- }
- $mysql = new sql();
- $mysql->setLogin("localhost", "root", "");
- $mysql->connect();
- // Create connection
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement