12345678910111213141516171819202122 |
- <?php
- /**
- * File: conn.php
- * User: Baoxu
- * Date: 16/3/8
- * Time: 23:31
- * Desc: 连接数据库
- */
- //数据库连接信息
- define("DB_HOST", "mysql_db"); //服务器主机IP或者主机名
- define("DB_USER", "baoxu"); //数据库用户名
- define("DB_PASS", ",."); //数据库密码
- define("DB_NAME", "library"); //数据库名
- //连接数据库
- $conn = mysql_connect(DB_HOST, DB_USER, DB_PASS);
- if(!$conn){
- die("数据库连接失败: " . mysql_error());
- }
- mysql_select_db(DB_NAME, $conn);
- mysql_query("SET NAMES 'utf8'");
|