修改 数据库连接方式
This commit is contained in:
parent
98570ec9f6
commit
b829a6f42e
|
@ -1,41 +1,28 @@
|
||||||
<?php
|
<?php
|
||||||
header ("Content-type:text/html;charset=utf-8");
|
header ("Content-type:text/html;charset=utf-8");
|
||||||
|
define('IN_CRONLITE', true);
|
||||||
define('SYS_KEY', 'lylme_key');
|
define('SYS_KEY', 'lylme_key');
|
||||||
define('SYSTEM_ROOT', dirname(__FILE__).'/');
|
define('SYSTEM_ROOT', dirname(__FILE__).'/');
|
||||||
define('ROOT', dirname(SYSTEM_ROOT).'/');
|
define('ROOT', dirname(SYSTEM_ROOT).'/');
|
||||||
|
require ROOT.'config.php';
|
||||||
include ROOT.'config.php';
|
if(!defined('SQLITE') && (!$dbconfig['user']||!$dbconfig['pwd']||!$dbconfig['dbname']))//检测安装
|
||||||
if(!$con =mysqli_connect($dbconfig['host'],$dbconfig['user'],$dbconfig['pwd'],$dbconfig['dbname'],$dbconfig['port'])) {
|
{
|
||||||
if(mysqli_connect_errno()==2002) {
|
@unlink(ROOT.'install/install.lock');
|
||||||
echo '连接数据库失败,数据库地址填写错误!';
|
header('Content-type:text/html;charset=utf-8');
|
||||||
} elseif(mysqli_connect_errno()==1045) {
|
echo '你还没安装!<a href="install/">点此安装</a>';
|
||||||
echo '连接数据库失败,数据库用户名或密码填写错误!';
|
exit();
|
||||||
} elseif(mysqli_connect_errno()==1049) {
|
|
||||||
echo '连接数据库失败,数据库名不存在!';
|
|
||||||
} else {
|
|
||||||
echo '连接数据库失败,['.mysqli_connect_errno().']'.mysqli_connect_error();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$GLOBALS['con'] = $con;
|
include_once(SYSTEM_ROOT."db.class.php");
|
||||||
mysqli_query($con,"set sql_mode = ''");
|
$DB=new DB($dbconfig['host'],$dbconfig['user'],$dbconfig['pwd'],$dbconfig['dbname'],$dbconfig['port']);
|
||||||
//字符转换,读库
|
|
||||||
mysqli_query($con,"set character set 'utf8'");
|
|
||||||
//写库
|
|
||||||
mysqli_query($con,"set names 'utf8'");
|
|
||||||
|
|
||||||
$rs= mysqli_query($con,"SELECT * FROM `lylme_config`");
|
|
||||||
|
$rs= $DB->query("SELECT * FROM `lylme_config`");
|
||||||
while($row = mysqli_fetch_assoc($rs)) {
|
while($row = mysqli_fetch_assoc($rs)) {
|
||||||
$conf[$row['k']]=$row['v'];
|
$conf[$row['k']]=$row['v'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
include_once(SYSTEM_ROOT."function.php");
|
include_once(SYSTEM_ROOT."function.php");
|
||||||
include_once(SYSTEM_ROOT."member.php");
|
include_once(SYSTEM_ROOT."member.php");
|
||||||
include_once(SYSTEM_ROOT."tj.php");
|
include_once(SYSTEM_ROOT."tj.php");
|
||||||
mysqli_query($con,'set names utf8');
|
$linksrows=$DB->num_rows($DB->query("SELECT * FROM `lylme_links`"));
|
||||||
$linksrows=mysqli_num_rows(mysqli_query($con, "SELECT * FROM `lylme_links`"));
|
$groupsrows=$DB->num_rows($DB->query("SELECT * FROM `lylme_groups`"));
|
||||||
$groupsrows=mysqli_num_rows(mysqli_query($con, "SELECT * FROM `lylme_groups`"));
|
?>
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
Loading…
Reference in New Issue