php文件链接数据库基本代码

<?php
	$conn=@mysql_connect("localhost","root","");
	if($conn==null)
		die("数据库连接失败1,因为你的账户密码错误");
	mysql_query("set names 'gb2312'");
	if(!mysql_select_db("root"))
	{
		die("数据库连接失败2,因为你的数据库名不对");
	}
?>

  

$conn=@mysql_connect("localhost","root","");括弧里分别填写  数据库路径 数据库用户名 数据库密码

if(!mysql_select_db("root"))  root的意思是数据库名

posted on 2014-02-09 09:14  谢寒  阅读(254)  评论(0编辑  收藏  举报

导航