Home  >  Article  >  php教程  >  php连接mysql数据库代码_php基础

php连接mysql数据库代码_php基础

WBOY
WBOYOriginal
2016-05-17 09:02:472631browse
复制代码 代码如下:

mysql_connect("localhost", "root","1981427") //连接位于localhost的服务器,用户名为root
?>


复制代码 代码如下:

@mysql_connect("localhost", "root","1981427")
or die("数据库服务器连接失败");
?>


复制代码 代码如下:

@mysql_connect("localhost", "root","1981427") //选择数据库之前需要先连接数据库服务器
or die("数据库服务器连接失败");
@mysql_select_db("test") //选择数据库mydb
or die("数据库不存在或不可用");
?>
Statement:
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