[BlueG mysql plugin] Check connection
#1

Hi. How can I check if the script connected to the database (using mysql_connect)? I would like prevent whole gamemode loading when the connection doesn't work.
Reply
#2

There is mine:
pawn Код:
ConnectMySQL()
{
    IMDb = mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
   
    if(IMDb && mysql_errno(IMDb) == 0)
    {
        printf("[MySQL]: Connection to database [%s] successfully established!", SQL_DB);
    }
    else
    {
        printf("[MySQL]: Connection to database [%s] failed!", SQL_DB);
    }
}
Reply
#3

pawn Код:
if(mysql_ping() < 0)
{
      print("MYSQL: Server failed to connect.");
      SendRconCommand( "exit" );
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)