Home  >  Article  >  Backend Development  >  PHP怎么验证数据库已连接

PHP怎么验证数据库已连接

WBOY
WBOYOriginal
2016-06-13 13:01:34871browse

PHP如何验证数据库已连接
mysql_connect
如何验证数据库已连接?
如:
$db = @mysql_connect($sql['host'], $sql['user'], $sql['pass']);

if (!$db) echo '没连接';

就可以了吧。
------解决方案--------------------
是的,那样就可以了。
------解决方案--------------------
$link = mysql_connect($server, $user, $password) 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