mysql连接失败时不显示错误消息
if( ! $this->remote_connection_id = @mysql_connect($vars['hostname'], $vars['username'], $vars['password'], TRUE))
{
die('Could not connect: ' . mysql_error());
}
只显示Could not connect:
尝试正确添加括号。
代替:
if( ! $a = foo())
采用:
if( !($a = foo()))
您没有收到错误的原因是因为连接成功。
尝试
$mysqli = new mysqli ( $vars ['hostname'], $vars ['username'], $vars ['password'], "test" );
if ($mysqli->connect_errno) {
printf ( "Connect failed: %s\n", $mysqli->connect_error );
}
else
{
echo "Am OK" ;
}
谢谢
:)
你有2个连接吗?像这样:
$link_lang_db = mysql_connect($conf_lang_db_host, $conf_lang_db_user, $conf_lang_db_password, 1) or die('Could not connect: ' . mysql_error($link_lang_db));
$link_editor_db = mysql_connect($conf_editor_db_host, $conf_editor_db_user, $conf_editor_db_password, 1) or die('Could not connect: ' . mysql_error($link_editor_db));
然后试试这个:
$result = mysql_query($query24f, $link_lang_db) or die("Error: " .mysql_error($link_lang_db));
希望它有所帮助。