标签:
织梦引用数据库连接
<?$db_config = require("data/common.inc.php");
$con = @mysql_connect($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd) or die(‘数据库连接失败:‘.mysql_error());
mysql_query("set names ‘gb2312‘",$con);
mysql_select_db($cfg_dbname,$con) or die(‘选择数据库失败:‘.mysql_error());
if (!$con)
{
die(‘Could not connect: ‘. mysql_error());
}
?>
phpcms引用数据库连接
<?
$db_config = require("caches/configs/database.php");
$con = @mysql_connect($db_config["default"]["hostname"],$db_config["default"]["username"],$db_config["default"]["password"]) or die(‘数据库连接失败:‘.mysql_error());
mysql_query("set names ‘gb2312‘",$con);
mysql_select_db($db_config["default"]["database"],$con) or die(‘选择数据库失败:‘.mysql_error());
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}
?>
标签:
原文地址:http://www.cnblogs.com/mrt-yyy/p/4450003.html