-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbconfig.php
More file actions
38 lines (36 loc) · 1.42 KB
/
Copy pathdbconfig.php
File metadata and controls
38 lines (36 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
//error_reporting(0);
class database{ //variable for connecting to the databases
public $dbhostname;
public $dbusername;
public $dbpassword;
public $dbname;
public $conn;
//Constructor for defining the variable for database
function __construct($hostname,$username,$password,$dbname){
$this->dbhostname=$hostname;
$this->dbusername=$username;
$this->dbpassword=$password;
$this->dbname=$dbname;
$this->conn = mysqli_connect($this->dbhostname,$this->dbusername,$this->dbpassword,$this->dbname);
}
//Function for checking if the connection has been established or not
function connectionCheck(){
if($this->conn){
echo "<script>console.log('Database Connection established!');</script>";
}
else{
echo "<script>console.log('Error in connecting with the Database. please check the connection.');window.alert('Error connection with server!. reload or try again later..')</script>";
}
}
//Function of query
function query($query){
$result = mysqli_query($this->conn,$query);
if(!$result){
echo "error";
}
return $result;
}
}
$database = new database('localhost','root','','musicstream'); //Class object created.
?>