PHP database connection method_PHP tutorial

WBOY
Release: 2016-07-13 17:05:04
Original
1038 people have browsed it

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('

could not connect to the database

please try again after a few moments.

');
}

$mysqli->set_charset("utf8");

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/630799.htmlTechArticlephp教程 数据库教程连接方法 /* database config */ $db_host= 'localhost'; $db_user= 'root'; $db_pass= '123'; $db_database= 'todo'; /* end config */ $link = @mysql教程_co...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!