Advertisement
zihadrizkyef

db_connect.php

Sep 3rd, 2016
188
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.     class DB_CONNECT {
  3.         function __construct() {
  4.             $this->connect();
  5.         }
  6.         function __destruct() {
  7.             $this->close();
  8.         }
  9.  
  10.         function connect() {
  11.             require_once __DIR__ . '/db_config.php';
  12.             $con = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysql_error());
  13.             $db = mysql_select_db(DB_DATABASE) or die(mysql_error()) or die(mysql_error());
  14.             return $con;
  15.         }
  16.  
  17.         function close() {
  18.             mysql_close();
  19.         }
  20.     }
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement