Help with inserts (MYSQL)
#1

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?
Reply
#2

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);
Reply
#3

I'm using mysql r7.

Which is better: mysql r7 or r38?
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)