一、文章配置文件
<?php
header("Content-type:text/html;charset=utf-8"); //設置爲utf8編碼
define('localhost','127.0.0.1'); //數據庫服務器的地址
define('USERNAME','root'); //數據庫的用戶名
define('PASSWORD','123456'); //數據庫的密碼
?>
<?php
require_once('config.php');//
//連庫
if(!($con=mysql_connect(localhost,USERNAME,PASSWORD))){
echo mysql_error();
}
//選庫
if(!mysql_select_db('samoye')){
echo mysql_error();
}
//設置字符集
if(!mysql_query('set names utf8')){
echo mysql_error();
}
?>