16.01.2010, 18:40
Код:
Im making my bans save to a database but I get an error in the my_log:This is my /ban:Код:[19:29:41] mysql_query("INSERT INTO 'bans' (name, ip, banner, reason, month, day, year) VALUES ('[RG]James','49','[RG]James','dipshit','1','16', '2010'"); [19:29:41] MySQL Query Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''bans' (name, ip, banner, reason, month, day, year) VALUES ('[RG]James','49','[R' at line 1 (Error ID 1064) -> Query returned false (0)
Will this work also? Havent been able to try it:pawn Код:if(strcmp(cmd, "/ban", true) == 0) { new giveplayerid; giveplayerid = ReturnUser(tmp); new giveplayer[MAX_PLAYER_NAME]; new string[256]; new sendername[MAX_PLAYER_NAME]; new playerip[20]; if(IsPlayerConnected(playerid)) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_RED, "USAGE: /ban [playerid/PartOfName] [reason]"); return 1; } giveplayerid = ReturnUser(tmp); if (PlayerInfo[playerid][pAdmin] >= 3) { if(IsPlayerConnected(giveplayerid)) { if(giveplayerid != INVALID_PLAYER_ID) { GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); GetPlayerName(playerid, sendername, sizeof(sendername)); new length = strlen(cmdtext); while ((idx < length) && (cmdtext[idx] <= ' ')) { idx++; } new offset = idx; new result[64]; while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) { result[idx - offset] = cmdtext[idx]; idx++; } result[idx - offset] = EOS; if(!strlen(result)) { SendClientMessage(playerid, COLOR_RED, "USAGE: /ban [playerid/PartOfName] [reason]"); return 1; } format(string, sizeof(string), "In Game Name: %s", giveplayer); SendClientMessage(giveplayerid,COLOR_YELLOW,string); format(string, sizeof(string), "Who Banned You: %s", sendername); SendClientMessage(giveplayerid,COLOR_YELLOW,string); BanStats(giveplayerid); format(string, sizeof(string), "Take a SS of this (F8) and go to rock-gaming.com"); SendClientMessage(giveplayerid,COLOR_GREEN,string); new year, month,day; getdate(year, month, day); GetPlayerIp(giveplayerid, playerip, 16); new query[128]; format(query, sizeof(query), "INSERT INTO 'bans' (name, ip, banner, reason, month, day, year) VALUES ('%s','%d','%s','%s','%d','%d', '%d')", giveplayer,playerip,sendername,result,month,day,year); mysql_query(query); format(string, sizeof(string), " %s was banned by %s, reason: %s (%d-%d-%d)", giveplayer, sendername, (result),month,day,year); SendClientMessageToAll(COLOR_YELLOW, string); BanLog(string); Kick(giveplayerid); return 1; } } else { format(string, sizeof(string), " %d is not an active player.", giveplayerid); SendClientMessage(playerid, COLOR_RED, string); } } else return SendClientMessage(playerid, RED, "ERROR: You are not an admin"); } return 1; }
thankspawn Код:new query[265]; new pip[20]; new ip[20]; GetPlayerIp(playerid, pip, 16); format(query, sizeof(query), "SELECT type FROM 'bans' WHERE ip = '%s'", ip); if(strcmp(pip, ip) == 1) { SendClientMessage(playerid, COLOR_RED, "You Are Banned From This Server"); SendClientMessage(playerid, COLOR_RED, "To Appeal This Ban Please Goto Out Forums"); SendClientMessage(playerid, COLOR_RED, "At http://www.rock-gaming.com[url=http://]"); return 1; } if(strcmp(pip, ip) == 0) { //other crap here