strange MySQL connect problem
#1

My server goes crazy if it can't connect to the db.. It have to print one time "** Server couldn't connect to the database, try again.. **" that, and one time this ** Server couldn't connect to the database, server shutdown.**,

(see the log below)

Код:
stock MySQLConnect()
{
    mysql_debug(1);
    mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
    if(mysql_ping() == -1) return CheckMySQL();
	return 1;
}

stock CheckMySQL()
{
	if(mysql_ping() == -1)
	{
		print("** Server couldn't connect to the database, try again.. **");
  		mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS); 
	    if(mysql_ping() == -1)
	    {
			print("** Server couldn't connect to the database, server shutdown.**");
	       	return SendRconCommand("exit");
	    }
	}
	return 1;
}
Код:
[14:26:25] ** Server couldn't connect to the database, try again.. **
[14:26:26] ** Server couldn't connect to the database, server shutdown.**
[14:26:26] ** Server couldn't connect to the database, try again.. **
[14:26:27] ** Server couldn't connect to the database, server shutdown.**
[14:26:27] ** Server couldn't connect to the database, try again.. **
[14:26:28] ** Server couldn't connect to the database, server shutdown.**
[14:26:28] ** Server couldn't connect to the database, try again.. **
[14:26:29] ** Server couldn't connect to the database, server shutdown.**
[14:26:30] ** Server couldn't connect to the database, try again.. **
[14:26:31] ** Server couldn't connect to the database, server shutdown.**
[14:26:31] ** Server couldn't connect to the database, try again.. **
[14:26:32] ** Server couldn't connect to the database, server shutdown.**
[14:26:32] ** Server couldn't connect to the database, try again.. **
[14:26:33] ** Server couldn't connect to the database, server shutdown.**
[14:26:33] ** Server couldn't connect to the database, try again.. **
[14:26:34] ** Server couldn't connect to the database, server shutdown.**
[14:26:34] ** Server couldn't connect to the database, try again.. **
[14:26:35] ** Server couldn't connect to the database, server shutdown.**
[14:26:35] ** Server couldn't connect to the database, try again.. **
[14:26:36] ** Server couldn't connect to the database, server shutdown.**
[14:26:36] ** Server couldn't connect to the database, try again.. **
[14:26:37] ** Server couldn't connect to the database, server shutdown.**
[14:26:37] ** Server couldn't connect to the database, try again.. **
[14:26:38] ** Server couldn't connect to the database, server shutdown.**
[14:26:38]  
[14:26:38] _______________________________________
[14:26:38][*] Server started[*]
[14:26:38] _______________________________________
[14:26:38]  
[14:26:38] Number of vehicle models: 13
[14:26:38] --- Server Shutting Down.
Reply
#2

try
pawn Код:
stock CheckMySQL(sqlhost[], sqluser[], sqlpass[], sqldb[])
{
    print("** Trying to connect to mysql server **");
    mysql_connect(sqlhost, sqluser, sqldb, sqlpass);
    if(mysql_ping()==1)
    {
        print("** Server connected **");
        return 1;
    }
    else
    {
        print("** Server couldn't connect to the database, try again.. **");
        mysql_connect(sqlhost, sqluser, sqldb, sqlpass);
        if(mysql_ping()==1)
        {
            print("** Server connected **");
            return 1;
        }
        else
        {
            print("** Server couldn't connect to the database, server shutdown.**");
            SendRconCommand("exit");
            return 0;
        }
    }
}
Reply
#3

Problem resolved, thx.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)