-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDBConnect.php
78 lines (54 loc) · 1.37 KB
/
DBConnect.php
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
class DBConnect
{
private $hostname = null;
private $username = null;
private $password = null;
private $dbhandle = null;
function __construct()
{
$this->hostname = "mysql.normtronics.com";
$this->username = "soldiercnorm";
$this->password = "pernell1";
}
public function getConnection(){
$this->dbhandle = mysql_connect($this->hostname, $this->username, $this->password) or die(mysql_error());
}
public function getDatabase($database){
mysql_select_db($database , $this->dbhandle) or die(mysql_error());
}
public function runQuery($query){
$result = mysql_query($query, $this->dbhandle);
print($result);
if(mysql_error() && strpos(mysql_error(),'username')){
print('Username already esist');
return 0;
}
if (mysql_error() && strpos(mysql_error(),'email')) {
print('Email already esist');
return 1;
}
mysql_close($this->dbhandle);
return $result;
}
public function getHostName(){
return $this->hostname;
}
public function getUserName(){
return $this->username;
}
public function getPassWord(){
return $this->password;
}
public function getDBHandle(){
return $this->dbhandle;
}
}
$DBtest = new DBConnect();
print($DBtest->getHostName()."\n");
print($DBtest->getUserName()."\n");
print($DBtest->getPassWord()."\n");
$DBtest->getConnection();
$DBtest->getDatabase('asylis2');
print($DBtest->getDBHandle());
?>