SA-MP Forums Archive
Help with inserts (MYSQL) - 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: Help with inserts (MYSQL) (/showthread.php?tid=507056)



Help with inserts (MYSQL) - Kan - 15.04.2014

Hello friends! I've a problem with insert a new line at my database.

My script is that:
pawn Код:
public OnRconLoginAttempt(ip[], password[], success) {
    new
        gQuery[200],
        gBuf[2][50],
        gTime[3],
        gDate[3],
        gLoop = -1,
        gIp[20],
        gName[25];
    gettime(gTime[0], gTime[1], gTime[2]);
    getdate(gDate[0], gDate[1], gDate[2]);
    format(gBuf[0], 50, "%02i:%02i:%02i", gTime[0], gTime[1], gTime[2]);
    format(gBuf[1], 50, "%02i/%02i/%04i", gDate[2], gDate[1], gDate[0]);
    while (++gLoop < MAX_PLAYERS) {
        GetPlayerIp(gLoop, gIp, sizeof(gIp));
        if (!strcmp(ip, gIp, true)) {
            format(gName, 25, getPlayerName(gLoop));
        }
    }
    mysql_format(gDB, gQuery, "insert into rcon_logs (name, ip, pass, hour, date, success) values ('%s', '%s', '%s', '%s', '%s', %i)", gName, ip, password, gBuf[0], gBuf[1], (success) ? 1 : 0);
    mysql_function_query(gDB, gQuery, false, "", "");
    return 1;
}
In the database looks like this:


Someone can help me pls?


Re: Help with inserts (MYSQL) - Kar - 15.04.2014

pawn Код:
format(gQuery, sizeof(gQuery), "INSERT INTO rcon_logs (name, ip, pass, hour, date, success) VALUES ('%s', '%s', '%s', '%s', '%s', %i)", gName, ip, password, gBuf[0], gBuf[1], (success) ? 1 : 0);
mysql_tquery(gDB, gQuery);



Re: Help with inserts (MYSQL) - Kan - 15.04.2014

I'm using mysql r7.

Which is better: mysql r7 or r38?


Re: Help with inserts (MYSQL) - Vince - 15.04.2014

Newer is mostly better.

Also, why are you using the 'g' prefix if none of the listed variables (except gDB) are actually globals? This is very good way to confuse people.