Home > php教程 > php手册 > 测试PHP连接MYSQL成功与否的代码

测试PHP连接MYSQL成功与否的代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:41:26
Original
846 people have browsed it

方法很简单:

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

复制代码 代码如下:


$link=mysql_connect("localhost","root","123");
if(!$link) echo "FAILD!连接错误,用户名密码不对";
else echo "OK!可以连接";
?>



其中mysql_connect( )函数的参数依次为:mysql服务器名或IP、mysql用户名,mysql用户密码。
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template