Mysql Trying 3 cases -
AroseKhanNiazi - 01.07.2015
pawn Код:
mysql_format(g_SQL, string, sizeof(string), "SELECT * FROM `bans` WHERE `bannick`='%e' OR `banip`='%e' AND banned=true LIMIT 1", PlayerInfo[playerid][pUserName],PlayerInfo[playerid][pIP]);
mysql_pquery(g_SQL, string, "CheckPlayerBan", "d", playerid);
How could i do to check for the ip or that banned nick but where the banned should be true it's a boolen on database.
As even if i will remove my bans it won't remove this record.
Re: Mysql Trying 3 cases -
Suicidal.Banana - 01.07.2015
Код:
"SELECT * FROM `bans` WHERE (`bannick`='%e' OR `banip`='%e') AND `banned`='1' LIMIT 1"
(not sure if the added brackets are needed, just is cleaner to read, the actual fix was expecting banned to be '1' instead of true)
Re: Mysql Trying 3 cases -
AroseKhanNiazi - 01.07.2015
thanks for this but another problem occurred
No error in mysql log
pawn Код:
format(string,sizeof(string),"NOW()+%d",60*60*24*days);
print(string);
mysql_format(g_SQL, string, sizeof(string), "UPDATE bans SET banby='%e',bannick='%e',banip='%e',banon=NOW(),banexpire=%s,banned=%d,banperma=%d WHERE banid=%d LIMIT 1",BanInfo[ServerInfo[sCurrentBanID]][BanBy],BanInfo[ServerInfo[sCurrentBanID]][BanNick],BanInfo[ServerInfo[sCurrentBanID]][BanIP],string,BanInfo[ServerInfo[sCurrentBanID]][Banned],BanInfo[ServerInfo[sCurrentBanID]][BanPerma],ServerInfo[sCurrentBanID]);
print(string);
mysql_tquery(g_SQL, string);
This won't just update, nothing there but there is code after this which gets executed this means this doesn't crash.
This is the log, i just used some print functions
Код:
[20:09:45] NOW()+604800
[20:09:45] UPDATE bans SET banby='Sasuke_Uchiha',bannick='Sasuke_Uchiha',banip='127.0.0.1',banon=NOW(),banexpire=NOW()+604800,banned=1,banperma=0 WHERE banid=6 LIMIT 1
Re: Mysql Trying 3 cases -
Prokill911 - 01.07.2015
Why are you using %e.....
You're calling strings AND Integers...
YET
You refer to everything as... %e....
Strings = '%s'
Integers = %d
Flots = %f
so why are you using %e... For everything
And again as above..
You're telling it up UPDATE... that exact column..
where banid=6
So it will only update fields that have "banid" as 6
Re: Mysql Trying 3 cases -
Suicidal.Banana - 01.07.2015
@Prokill911; the %e is some automatically escaped version of the variable, not a fan of it either but apparently its common practice,
mysql_format wiki page says:
Код:
Placeholder | Meaning
%e <<<< | Escapes data directly without the need to call mysql_escape_string() before
%s | Inserts a string.
... etc ...
@AroseKhanNiazi; like i just explained in
your other thread, your better off switching to timestamps anyway :P
Re: Mysql Trying 3 cases -
AroseKhanNiazi - 01.07.2015
Okay just converted still not working :/
debug
pawn Код:
[23:27:32] UPDATE bans SET banby='Sasuke_Uchiha',bannick='Sasuke_Uchiha',banip='127.0.0.1',banon=UNIX_TIMESTAMP(),banexpire=UNIX_TIMESTAMP()+432000,banned=1,banperma=0,bandate=NOW() WHERE banid=7 LIMIT 1
code
pawn Код:
mysql_format(g_SQL, string, sizeof(string), "UPDATE bans SET banby='%e',bannick='%e',banip='%e',banon=UNIX_TIMESTAMP(),banexpire=UNIX_TIMESTAMP()+%d,banned=%d,banperma=%d,bandate=NOW() WHERE banid=%d LIMIT 1",BanInfo[ServerInfo[sCurrentBanID]][BanBy],BanInfo[ServerInfo[sCurrentBanID]][BanNick],BanInfo[ServerInfo[sCurrentBanID]][BanIP],BanInfo[ServerInfo[sCurrentBanID]][BanExpire],BanInfo[ServerInfo[sCurrentBanID]][Banned],BanInfo[ServerInfo[sCurrentBanID]][BanPerma],ServerInfo[sCurrentBanID]);
print(string);
Re: Mysql Trying 3 cases -
Suicidal.Banana - 01.07.2015
Dont use the UNIX_TIMESTAMP() function in sa-mp, just use gettime() (sa-mp's timestamp function)
Like so:
Код:
new string[128],
curr_timestamp = gettime(); // ADDED
mysql_format(g_SQL, string, sizeof(string),
"UPDATE bans SET banby='%e',bannick='%e', banip='%e', banon=%d, banexpire=%d, banned=%d, banperma=%d, bandate=NOW() WHERE banid=%d LIMIT 1", // UPDATED
BanInfo[ServerInfo[sCurrentBanID]][BanBy],
BanInfo[ServerInfo[sCurrentBanID]][BanNick],
BanInfo[ServerInfo[sCurrentBanID]][BanIP],
curr_timestamp, // ADDED
(curr_timestamp+BanInfo[ServerInfo[sCurrentBanID]][BanExpire]), // UPDATED
BanInfo[ServerInfo[sCurrentBanID]][Banned],
BanInfo[ServerInfo[sCurrentBanID]][BanPerma],
ServerInfo[sCurrentBanID]
);
print(string);
Re: Mysql Trying 3 cases -
AroseKhanNiazi - 01.07.2015
just asking will it be same time on mysql database as gettime as unban will work with mysql database.
Re: Mysql Trying 3 cases -
Suicidal.Banana - 01.07.2015
Yes, both are based on the same system clock (assuming the sa-mp server and the database server are on the same machine)
Re: Mysql Trying 3 cases -
AroseKhanNiazi - 02.07.2015
pawn Код:
new unbanon=gettime()+BanInfo[ServerInfo[sCurrentBanID]][BanExpire];
mysql_format(g_SQL, string, sizeof(string),
"UPDATE bans SET banby='%e',bannick='%e', banip='%e',banexpire=%d, banned=%d, banperma=%d, bandate=NOW() WHERE banid=%d LIMIT 1",
BanInfo[ServerInfo[sCurrentBanID]][BanBy],
BanInfo[ServerInfo[sCurrentBanID]][BanNick],
BanInfo[ServerInfo[sCurrentBanID]][BanIP],
unbanon,
BanInfo[ServerInfo[sCurrentBanID]][Banned],
BanInfo[ServerInfo[sCurrentBanID]][BanPerma],
ServerInfo[sCurrentBanID]);
even did this code still no error in log and not even updating
Tried it setting banexpire type as timestamp and bigint both way it won't work