-
Notifications
You must be signed in to change notification settings - Fork 0
/
conn.php
61 lines (58 loc) · 1.37 KB
/
conn.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
<?php
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
switch ($errno)
{
//严重错误
case E_ERROR:
case E_USER_ERROR:
echo $errfile." ".$errline.":".$errstr;
break;
case E_WARNING:
case E_USER_WARNING:
//echo $errfile." ".$errline.":".$errstr;
//break;
default:
return true;
}
echo "<br>Sorry! Error Arise!<br>Click <a href='/'>here</a> to go to home page~";
/* Don't execute PHP internal error handler */
die();
}
//设置错误处理程序
set_error_handler("myErrorHandler");
try{
$link_mysql = mysql_pconnect("127.0.0.1","root","142232");
mysql_query("SET NAMES 'utf8'");
if(!$link_mysql)
throw new Exception("Can't connect the database server!");
mysql_select_db("iron_cms",$link_mysql) or die("Have no such database!");
}catch(Exception $e){
die($e->getMessage());
}
//数据库函数
function getresult($query)
{
return mysql_query($query);
}
function getresultNumrows($result)
{
return mysql_num_rows($result);
}
function getresultArray($result)
{
return mysql_fetch_array($result);
}
function getresultRow($result)
{
return mysql_fetch_row($result);
}
function getresultData($result,$row,$field)
{
return mysql_result($result,$row,$field);
}
function getaffectedrows()
{
return mysql_affected_rows();
}
?>