一、文章配置文件
<?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();
}
?>