private
$db_pwd;
//数据库密码
private
$db_database;
//数据库名
private
$conn;
//数据库连接标识;
private
$sql;
//sql执行的语句
private
$result;
//query的资源标识符
private
$coding;
//数据库编码,gbk,utf8,gb2312
private
$show_error
=
true;
//本地调试使用,打印错误
public
function
__construct($db_host,
$db_user,
$db_pwd,
$db_database,
$coding)
{
$this-db_host
=
$db_host;
$this-db_user
=
$db_user;
$this-db_pwd
=
$db_pwd;
$this-db_database
=
$db_database;
$this-coding
=
$coding;
$this-connect();
}
private
function
connect()
{
$this-conn
=
@mysql_connect($this-db_host,
$this-db_user,
$this-db_pwd);
if
(!$this-conn)
{
//show_error开启时,打印错误
if
($this-show_error)
{
$this-show_error('错误提示:链接数据库失败!');
}
}
if
(!@mysql_select_db($this-db_database,
$this-conn))
{
//打开数据库失败
if
($this-show_error)
{
$this-show_error('错误提示:打开数据库失败!');
}
}
if
(!@mysql_query("set
names
$this-coding"))
{
//设置编码失败
if
($this-show_error)
{
$this-show_error('错误提示:设置编码失败!');
}
}
}
}
php页面链接数据库的介绍就聊到这里吧 , 感谢你花时间阅读本站内容 , 更多关于php7链接数据库、php页面链接数据库的信息别忘了在本站进行查找喔 。
推荐阅读
- mac双系统虚拟机区别,mac双系统和虚拟机的区别
- 关于怎么使用go语言中文字幕的信息
- mongodb数据文件存储位置,mongodb存储文件如何存储
- 特斯拉电视怎么更换网络,特斯拉有线投屏
- 手机计算机的java代码 手机计算机的java代码是什么
- 理发店公众号运营方案,美发公众号简介怎么写
- 国外视频号怎么起号,国外微信视频号
- vb.net如何切图美化界面,vbnet tabpage
- php上如何备份数据库 php 备份数据库