php教程 數據庫教程連接方法
/* database config */
$db_host = 'localhost';
$db_user = 'root';
$db_pass = '123';
$db_database = 'todo';/* end config */
$link = @mysql教程_connect($db_host,$db_user,$db_pass) or die('unable to establish a db connection');mysql_set_charset('utf8');
mysql_select_db($db_database,$link);
//數據庫連接代碼二
error_reporting(e_all ^ e_notice);
$db_host = '';
$db_user = '';
$db_pass = '';
$db_name = '';@$mysqli = new mysqli($db_host, $db_user, $db_pass, $db_name);
if (mysqli_connect_errno()) {
die('<h1>could not connect to the database</h1><h2>please try again after a few moments.</h2>');
}$mysqli->set_charset("utf8");