PHP5连接MySql数据库代码

<?php 



// Set the database access information as constants:
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', 'root');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'sitename');


// Make the connection:
$dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error() );


// Set the encoding...
mysqli_set_charset($dbc, 'utf8');
?>

猜你喜欢

转载自blog.csdn.net/sinat_30658665/article/details/80285970