/*
* SAE_MYSQL_USER:用户名
* SAE_MYSQL_PASS:密码:
* SAE_MYSQL_HOST_M:主库域名
* SAE_MYSQL_HOST_S:库域名
* SAE_MYSQL_PORT:端口:
* SAE_MYSQL_DB数据库名
*
* 详细说明:页面编码要数据库编码现乱码
* 或者连接数据库设置mysql_set_charset()
*
*/
$link = mysql_connect ( SAE_MYSQL_HOST_M . ':' . SAE_MYSQL_PORT, SAE_MYSQL_USER, SAE_MYSQL_PASS )
if ($link) {
mysql_select_db ( SAE_MYSQL_DB, $link )
mysql_set_charset("utf-8")
echo "success"
mysql_free_result ( $result )
} else {
echo "sorry"
}
?>
$link=mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS)附:
<?php
// 连主库
$link=mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS)
// 连从库
// $link=mysql_connect(SAE_MYSQL_HOST_S.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS)
if($link)
{
mysql_select_db(SAE_MYSQL_DB,$link)
//your code goes here
}
?>
我有现成的代码。$db['default']['hostname'] = sae_mysql_host_m//主库
$db['default']['hostname_s'] = sae_mysql_host_s//从库
$db['default']['username'] = sae_mysql_user
$db['default']['password'] = sae_mysql_pass
$db['default']['database'] = sae_mysql_db
$db['default']['port'] = sae_mysql_port用这些参数替代
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)