Home > Backend Development > PHP Tutorial > 测试php连接mysql是否成功的代码分享_php实例

测试php连接mysql是否成功的代码分享_php实例

WBOY
Release: 2016-06-07 17:22:20
Original
923 people have browsed it

方法很简单:

将下面的代码保存为test.php,放到web目录里面执行即可。

复制代码 代码如下:

/**
* 测试php与mysql连接
* 编辑:www.php.net
*/
$link=mysql_connect("localhost","root","123");
if(!$link) echo "FAILD!连接错误,用户名密码不对";
else echo "OK!可以连接";
?>

其中mysql_connect( )函数的参数依次为:mysql服务器名或IP、mysql用户名,mysql用户密码。

Related labels:
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