【发布时间】:2013-06-20 16:27:36
【问题描述】:
$mysqlServer = "***";
$mysqlDb = "***";
$mysqlUser = "***";
$mysqlPass = "***";
$conn = mysqli_connect($mysqlServer, $mysqlUser, $mysqlPass) or die("failed to connect to db");
mysqli_select_db($conn, $mysqlDb) or die("failed to connect select db");
我有这个代码,它的工作没有任何问题。但是如果我尝试输入错误的 sql server 或测试它以执行错误。这将显示:
Warning: mysqli_connect(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
failed to connect select db
如果在连接 sql 服务器时出现问题,我不希望显示警告。我只想显示我自己的错误。
【问题讨论】:
-
在命令前加一个@符号,例如
@mysqli_connect
标签: php