SA-MP Forums Archive
[MySQL] Updating Player's Ban Information - 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] Updating Player's Ban Information (/showthread.php?tid=466392)



Banning Player and inserting the Banned row [MySQL] - Patrick - 27.09.2013

Alright, first of my problem is, I don't know what's wrong in my command, because as I can see it is right, but for other people might able to see the probably I'm facing, Quick Explanation: when I ban a player it doesn't update the player's Banned Variable, it says 0, it should be 1 on phpMyAdmin

Banning Stock
pawn Код:
stock BanPlayer(playerid)
{
    KickEx(playerid);
    TotalBannedPlayers++;
   
    new Query[128];
    format(Query, sizeof(Query), "UPDATE `bans` SET  `Banned` = 1 WHERE Username = '%s';", PlayerName(playerid));
    mysql_query(Query);
}
Picture


PS: I'm using MySQL R6, since I'm used to it, before you comment use R7, I'll learn and study R7 when I do have extra time


Re: [MySQL] Updating Player's Ban Information - tyler12 - 27.09.2013

Execute the query in phpmyadmin to see the error it's causing. I'm not too sure you need a semi-colon (;) on the end of the query though.


Re: [MySQL] Updating Player's Ban Information - Patrick - 27.09.2013

Alright, here's my Debug result Tyler12 It does say Successfully executed. but for some reason it doesn't set the variable to 1 in phpmyadmin

pawn Код:
[18:18:35] >> mysql_query( Connection handle: 1 )

[18:18:35] CMySQLHandler::Query(UPDATE `bans` SET  `Banned` = 1 WHERE Username = 'pds2012';) - Successfully executed.

[18:18:35] >> mysql_real_escape_string( Connection handle: 1 )

[18:18:35] CMySQLHandler::EscapeString(... test ... ,,, \ --[[); - Escaped 24 characters to ... test ... ,,, \\ --[[.

[18:18:35] >> mysql_query( Connection handle: 1 )

[18:18:35] CMySQLHandler::Query(INSERT INTO `bans` (Username, IpAdress, Reason, BannedBy) VALUES ('pds2012', 'pds2012', '... test ... ,,, \\ --[[', 'pds2012')) - Successfully executed.

[18:18:35] >> mysql_query( Connection handle: 1 )
MySQL Structure ( Image )


PS: I also tried removing ; at the last, but no. it still don't work


Re: [MySQL] Updating Player's Ban Information - x96664 - 27.09.2013

pawn Код:
format(Query, sizeof(Query), "UPDATE `bans` SET  `Banned` = 1 WHERE Username = '%s';", /*shouldn't there be something?*/,PlayerName(playerid));



Banning Player and inserting the Banned row [MySQL] - Patrick - 27.09.2013

I only have 1 function, and I don't need another variable for banned, since it's automatically set to 1.

Anyone could have a solution for this problem?

My code looks fine

pawn Код:
format(Query, sizeof(Query), "UPDATE `bans` SET  `Banned` = 1 WHERE Username = '%s'",PlayerName(playerid));