SA-MP Forums Archive
How to check this ? (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: How to check this ? (MySQL) (/showthread.php?tid=313355)



How to check this ? (MySQL) - Dokins - 25.01.2012

This doesnt work, but it un-bans (without the rows > 1 part), but I wanted to check if the account was valid....How would I get this to work

pawn Код:
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `PlayerName` = '%s'", string);
    mysql_store_result();
    new rows = mysql_num_rows();
    if(rows > 0)
    {
        TUnbanPlayer(string);
        format(string, sizeof(string), "You have unbanned account(Temp Ban) %s", string);
        SendClientMessage(playerid, COLOUR_REALRED, string);
    }
    if(rows == 0)
    {
        SendClientMessage(playerid, COLOUR_GREY, "There are no accounts found with that name.");
    }
    mysql_free_result();



Re: How to check this ? (MySQL) - Snowman12 - 25.01.2012

pawn Код:
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `PlayerName` = '%s'", string);
    mysql_query(query); // No query line
    mysql_store_result(); // "Error nothing to store"
    new rows = mysql_num_rows();
    if(rows > 0)
    {
        TUnbanPlayer(string);
        format(string, sizeof(string), "You have unbanned account(Temp Ban) %s", string);
        SendClientMessage(playerid, COLOUR_REALRED, string);
    }
    if(rows == 0)
    {
        SendClientMessage(playerid, COLOUR_GREY, "There are no accounts found with that name.");
    }
    mysql_free_result();
Very wrong code...

pawn Код:
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `PlayerName` = '%s'", string);
    mysql_store_result();
    new rows = mysql_num_rows();
    if(rows > 0)
    {
        TUnbanPlayer(string);
        format(string, sizeof(string), "You have unbanned account(Temp Ban) %s", string);
        SendClientMessage(playerid, COLOUR_REALRED, string);
    }
    if(rows == 0)
    {
        SendClientMessage(playerid, COLOUR_GREY, "There are no accounts found with that name.");
    }
    mysql_free_result();



Re: How to check this ? (MySQL) - Dokins - 25.01.2012

Ahh, that makes sense, I'm just getting used to mysql!