MySQL storing result as a variable
#1

Hello

I am trying to learn how to use MySQL with PAWN and I have this quick inquiry. How would I go about storing the result of a query into a variable, so I could show it in a dialog?

Here's what I got:
(I am trying to show the reason of the ban to the player in a dialog)
pawn Код:
// This is inside an if statement, which explains the indentation.
        new reason[128]; // Variable I would like to store the result in.
        format(query, sizeof(query), "SELECT reason FROM `bans` WHERE IP = '%s'", GetName(playerid)); // Format query (I already got the player's IP)
        mysql_query(query);// Store query
        mysql_store_result();// Store the result
        // And here is where I want to store the result into a variable
        format(ccstring, sizeof(ccstring), "We're sorry but you're IP is banned from the server.\nIf you would like to appeal, please appeal on our website\nat {0320FF}"website"\n\nReason: %s", reason); // Format the dialog
        ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "{FF0303}[X]{FFFFFF} Banned", ccstring, "Okay", ""); // Show the dialog
        Kick(playerid); // Kick the player because he's banned.
// Rest of code
Reply


Messages In This Thread
MySQL storing result as a variable - by DBan - 04.07.2012, 10:34
Re: MySQL storing result as a variable - by Sinner - 04.07.2012, 10:49
Respuesta: MySQL storing result as a variable - by [DOG]irinel1996 - 04.07.2012, 10:54
Re: MySQL storing result as a variable - by DBan - 04.07.2012, 10:59
Re: Respuesta: MySQL storing result as a variable - by Sinner - 04.07.2012, 11:14

Forum Jump:


Users browsing this thread: 1 Guest(s)