02.07.2018, 15:55
I wanted to do the opposite. In "if" we managed to connect and "else" failed connection.
Example:
Question:
Is this correct?
on
Код:
MySQL_Connect() { new MySQLOpt: option_id = mysql_init_options(); mysql_set_option(option_id, AUTO_RECONNECT, true); g_SQL = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, option_id); if(g_SQL == MYSQL_INVALID_HANDLE || mysql_errno(g_SQL) != 0) { print("Failed to connect to the database."); SendRconCommand("exit"); return 1; } print("Connection to the database has been established."); return 1; }
Код:
MySQL_Connect() { new MySQLOpt: option_id = mysql_init_options(); mysql_set_option(option_id, AUTO_RECONNECT, true); g_SQL = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, option_id); if(g_SQL == MYSQL_INVALID_HANDLE || mysql_errno(g_SQL) != 0) { // Connect MySQL } else { // No connect MySQL } return 1; }
Is this correct?
Код:
if(g_SQL == MYSQL_INVALID_HANDLE || mysql_errno(g_SQL) != 0)
Код:
if(g_SQL == MYSQL_INVALID_HANDLE || mysql_errno(g_SQL) == 0)