Hadi1989

Untitled

Jul 5th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. <?php
  2.     define('db_host', 'localhost');
  3.     define('db_user', 'root');
  4.     define('db_pass', '');
  5.     define('db_name', 'crud');
  6.    
  7.     class db_connect{  
  8.         public $host = db_host;
  9.         public $user = db_user;
  10.         public $pass = db_pass;
  11.         public $dbname = db_name;
  12.         public $conn;
  13.         public $error;
  14.        
  15.         public function connect(){
  16.             $this->conn = new mysqli($this->host, $this->user, $this->pass, $this->dbname);
  17.             if(!$this->conn){
  18.                 $this->error = "Fatal Error: Can't connect to database" . $this->connect->connect_error();
  19.                 return false;
  20.             }
  21.         }
  22.     }  
  23. ?>
Add Comment
Please, Sign In to add comment