Problem connecting to mysql server.
#1

Function :
pawn Code:
public MySQLConnect(sqlhost[], sqluser[],database[], sqlpass[])
{
    print("MYSQL: Attempting to connect to server...");
    mysql_connect(sqlhost, sqluser,database, sqlpass);
    if(mysql_ping()==0)
    {
        print("MYSQL: Database connection established.");
        return 1;
    }
    else
    {
        print("MYSQL: Connection error, retrying...");
        mysql_reconnect();
        if(mysql_ping()==0)
        {
            print("MYSQL: Reconnection successful. We can continue as normal.");
            return 1;
        }
        else
        {
            print("MYSQL: Could not reconnect to server, terminating server...");
            SendRconCommand("exit");
            return 0;
        }
    }
}
Called with :
pawn Code:
MySQLConnect(MYSQL_HOST,MYSQL_USER,MYSQL_DB,MYSQL_PASS);
Gives me :
Code:
----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3b R2, ©2005-2010 SA-MP Team

[06:24:17] filterscripts = ""  (string)
[06:24:17] 
[06:24:17] Server Plugins
[06:24:17] --------------
[06:24:17]  Loading plugin: mysql
[06:24:17] 

  > MySQL plugin R5 successfully loaded.

[06:24:17]   Loaded.
[06:24:17]  Loaded 1 plugins.

[06:24:17] 
[06:24:17] Filter Scripts
[06:24:17] ---------------
[06:24:17]   Loaded 0 filter scripts.

[06:24:17] 
----------------------------------
[06:24:17]  v0
[06:24:17] ----------------------------------

[06:24:17] MYSQL: Attempting to connect to server...
[06:24:18] MYSQL: Connection error, retrying...
[06:24:18] MYSQL: Could not reconnect to server, terminating server...
[06:24:18] Number of vehicle models: 0
[06:24:18] --- Server Shutting Down.
[06:24:18] 

  > MySQL plugin unloaded.
LE : I double checked the mysql db , the db works ok.
Reply
#2

It seems that the error is in checking if the sql connection is ok or not , plese someone give me a proper way to test my sql connection .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)