Hello,
I am trying to connect with the database but the file contains OOP programing that is little bit unfimiliar for me if anyone help me out in connecting with the database.
Db_connect.php
<?php
class DB_Connect {
var $dbuser;
var $dbpass;
var $dbname;
var $dbhost;
// constructor
function __construct() {
}
// destructor
function __destruct() {
// $this->close();
}
// Connecting to database
public function connect() {
require_once 'include/config.php';
$this->dbuser = 'rankdroid';
$this->dbpass = 'droid1234';
$this->dbname = 'rankdroid';
$this->dbhost = 'localhost';
// connecting to mysql
$this->dbc = mysqli_connect($this->dbuser, $this->dbpass, $this->dbname, $this->dbhost) or die('Error connecting to DB');
//$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
// selecting database
//mysql_select_db(DB_DATABASE);
// return database handler
return $con;
}
public function query($sql)
{
return mysqli_query($this->dbc, $sql) or or die('Error:'.mysqli_error($this->dbc).', query: '.$sql);
}
public function fetch($sql)
{
$array = mysqli_fetch_array($this->query($sql));
return $array;
}
// Closing database connection
public function close() {
mysql_close();
}
}
?>
DB_Functions.php
`class DB_Functions {
private $db;
//put your code here
// constructor
function __construct() {
require_once 'DB_Connect.php';
// connecting to database
$this->db = new DB_Connect();
$this->db->connect();
}
// destructor
function __destruct() {
}
/**
* Random string which is sent by mail to reset password
*/
`