时间:2021-07-01 10:21:17 帮助过:23人阅读
以前:
// $conn=mysql_connect("localhost","root","");
// $db=mysql_select_db("web_scoring_system",$conn)or die("数据库连接失败:".mysql_error());
// mysql_query("set names utf8");
新:
$link = mysqli_connect(
‘localhost‘, /* The host to connect to 连接MySQL地址 */
‘root‘, /* The user to connect as 连接MySQL用户名 */
‘‘, /* The password to use 连接MySQL密码 */
‘dbname‘); /* The default database to query 连接数据库名称*/
if (!$link) {
printf("Can‘t connect to MySQL Server. Errorcode: %s ", mysqli_connect_error());
exit;
}
mysqli_query($link,‘set names utf8‘);
php5.5过渡--mysql连接
标签:mysq 数据库连接 mysql用户 密码 code default select 连接失败 efault