forked from ogamespec/ogame-opensource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.php
48 lines (42 loc) · 1.33 KB
/
db.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
<?php
function dbconnect ($db_host, $db_user, $db_pass, $db_name)
{
$db_connect = @mysql_connect($db_host, $db_user, $db_pass);
$db_select = @mysql_select_db($db_name);
if (!$db_connect) {
die("<div style='font-family:Verdana;font-size:11px;text-align:center;'><b>Unable to establish connection to MySQL</b><br>".mysql_errno()." : ".mysql_error()."</div>");
} elseif (!$db_select) {
die("<div style='font-family:Verdana;font-size:11px;text-align:center;'><b>Unable to select MySQL database</b><br>".mysql_errno()." : ".mysql_error()."</div>");
}
}
function dbquery ($query, $mute=FALSE)
{
global $query_counter, $query_log;
$query_counter ++;
$query_log .= $query . "<br>\n";
$result = @mysql_query($query);
if (!$result && $mute==FALSE) {
echo "$query <br>";
echo mysql_error();
Debug ( mysql_error() . "<br>" . $query . "<br>" . BackTrace () ) ;
return false;
}
else return $result;
}
function dbrows ($query)
{
$result = @mysql_num_rows($query);
return $result;
}
function dbarray ($query)
{
$result = @mysql_fetch_assoc($query);
if (!$result) {
echo mysql_error();
return false;
}
else return $result;
}
function dbfree ($result) {
@mysql_free_result ($result);
}