-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_mysql.php
executable file
·75 lines (65 loc) · 1.37 KB
/
db_mysql.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
<?php
global $stream, $declared_class_db;
if (!$stream && $declared_class_db!="yes")
{
class db
{
function graberrordesc()
{
$this->error=mysql_error();
return $this->error;
}
function graberrornum()
{
$this->errornum=mysql_errno();
return $this->errornum;
}
function connect()
{
global $mysql_host, $mysql_username, $mysql_password, $mysql_dbname;
$this->db = @mysql_connect($mysql_host,$mysql_username,$mysql_password);
@mysql_select_db($mysql_dbname, $this->db);
@mysql_set_charset( 'utf8' , $this->db );
}
function do_query($query, $ret)
{
$this->result = @mysql_query($query, $this->db);
if (!$this->result || !$ret)
{
echo "There was an error in the sql statement.<br /> mysql said: ".$this->graberrordesc();
return "bad";
}
else
{
if ($ret=="array")
{
$this->return = array();
while ($row = @mysql_fetch_row($this->result))
{
$this->return[] = $row;
}
}
elseif ($ret=="one")
{
$this->return = @mysql_result($this->result,0,0);
}
elseif ($ret=="row")
{
$this->return = @mysql_fetch_row($this->result);
}
else
{
$this->return = "bad";
}
return $this->return;
}
}
function close()
{
@mysql_close($this->db);
}
}
$declared_class_db = "yes";
}
$stream = new db;
$stream->connect();