forked from nbtafelberg/opensimscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.php
49 lines (39 loc) · 1.01 KB
/
database.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
<?php
$con = mysqli_connect($databasehost, $databaseusername, $databasepassword);
mysqli_select_db($con,"robust");
mysqli_set_charset($con, 'utf8mb4');
/**
$localcon= mysqli_connect("127.0.0.1",$localdbusername,$localdbpassword);
mysqli_set_charset($localcon, 'utf8mb4');
**/
function pcGetRecordFrom($db, $query) {
$r = mysqli_query($db, $query);
if (!$r) {
echo "Error in " . $query;
}
$data = "";
$found = False;
$resultx = "";
$numrows = mysqli_num_rows($r);
if ($numrows > 0) {
while ($row = mysqli_fetch_assoc($r)) {
return $row;
}
}
return $resultx;
}
function pcGetDataFrom($db, $query, $field) {
$r = mysqli_query($db, $query);
$data = "";
$found = False;
$resultx = "";
$numrows = mysqli_num_rows($r);
if ($numrows > 0) {
while ($row = mysqli_fetch_assoc($r)) {
$found = True;
$resultx = $row[$field] . "";
break;
}
}
return $resultx;
}