SA-MP Forums Archive
MySQL connect - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL connect (/showthread.php?tid=345436)



MySQL connect - dannyk0ed - 25.05.2012

I have some warnings, i believe this is why i get a error 19 on samp-server
pawn Код:
#define MYSQL_HOST "Wont Show"
#define MYSQL_USER "Wont show"
#define MYSQL_PASS "Wont show"
#define MYSQL_DB   "erpgserver"
I removed the IP and other because of hackers.

pawn Код:
public MySQLConnect(sqlhost[], sqluser[], sqlpass[], sqldb[])
{
    FuncLog("MySQLConnect");
    print("MYSQL: Attempting to connect to server...");
    new MySQL:connection;
    mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB, connection, 1);
    if(mysql_ping() == 0)
    {
        print("MYSQL: Database connection established.");
        return 1;
    }
    else
    {
        print("MYSQL: Could not connect! Retrying...");
        mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB, connection, 1);
        if(mysql_ping()==0)
        {
           
            return 1;
        }
        else
        {
            print("MYSQL: Could not reconnect to Database! Terminating server...");
            SendRconCommand("exit");
            return 0;
        }
    }
}
pawn Код:
WCRP.pwn(48915) : warning 213: tag mismatch
WCRP.pwn(48915) : warning 202: number of arguments does not match definition
WCRP.pwn(48924) : warning 213: tag mismatch
WCRP.pwn(48924) : warning 202: number of arguments does not match definition



Re: MySQL connect - SuperViper - 25.05.2012

Both mysql_ping lines should look like this:

pawn Код:
if(mysql_ping(mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB, connection, 1)) == -1)
You should also remove the mysql_connect above the mysql_ping lines.


Re: MySQL connect - dannyk0ed - 25.05.2012

Still the same warnings


Re: MySQL connect - Pizzy - 25.05.2012

Can you tell us which lines are the warnings? Would help.


Re: MySQL connect - dannyk0ed - 25.05.2012

pawn Код:
mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB, connection, 1);
That gets the warnings..


Re: MySQL connect - Pizzy - 25.05.2012

I'm not too sure what MySQL plugin you are using - But mine works as the following format (Which you should try):

pawn Код:
mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
Obviously change the text around according to your details, and goodluck.


Re: MySQL connect - Vince - 25.05.2012

I think StrickenKid's plugin uses the MySQL: tag. BlueG's plugin does not.


Re: MySQL connect - qinaixiuor - 25.05.2012

BlueG's plugin does not.


Re: MySQL connect - Kirollos - 25.05.2012

try remove the #define MYSQL_HOST

and do mysql_connect("Wont Show", "Wont Show" and etc...);


Re: MySQL connect - MadeMan - 25.05.2012

Show the native of mysql_connect from the mysql include file you are using (#include).