-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofileDB.php
More file actions
61 lines (51 loc) · 1.02 KB
/
profileDB.php
File metadata and controls
61 lines (51 loc) · 1.02 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
// Database connectivity
// Change the username, password, and database to the correct values for your database
$db_host = "DATABASE HOST";
$db_user = "DATABASE USER NAME";
$db_password = "DATABASE PASSWORD";
$db_name = "DATABASE_NAME";
// TryOpenDb and CloseDb - Open and close the database.
$DbLink = FALSE;
$DbError = "";
function TryOpenDb()
{
global $DbLink;
global $DbError;
global $db_host;
global $db_user;
global $db_password;
global $db_name;
/* Connecting, selecting database */
$DbLink = new mysqli($db_host, $db_user, $db_password, $db_name);
if (mysqli_connect_error())
{
$DbError = mysqli_connect_error();
return FALSE;
}
$DbLink->autocommit(FALSE);
return $DbLink;
}
function CloseDb()
{
global $DbLink;
if ($DbLink)
{
$DbLink->commit();
$DbLink->close();
$DbLink = FALSE;
}
}
function abortAndExit()
{
global $DbLink;
global $DbError;
print "Aborting database communication: " . $DbError;
if ($DBLink) {
$DbLink->rollback();
$DbLink->close();
$DbLink = FALSE;
}
exit();
}
?>