SA-MP Forums Archive
How to set a variable to mysql_store_result? - 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 set a variable to mysql_store_result? (/showthread.php?tid=314459)



How to set a variable to mysql_store_result? - Dokins - 29.01.2012

How do I use the result of this below to put into another query, How do I basically assign a variable to mysql_store_result();

Look at this: doesnt work.

pawn Код:
CMD:findnumber(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    if(Phonebook[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You do not have a phonebook, you can buy one from a store.");
    new player[24],string[128], number[16], query[256];
    if(sscanf(params, "s[24]",player)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /findnumber [player name]");
   
   
    format(query, sizeof(query), "SELECT `Number` FROM `accounts` WHERE `PlayerName` = '%s'", player);
    mysql_query(query); // No query line
    mysql_store_result(); // "Error nothing to store"
    new rows = mysql_num_rows();
    if(rows > 0)
        {
            format(string, sizeof(string), "%s - %d", player, number);
            SendClientMessage(playerid, COLOUR_WHITE, string);
        }
    if(rows == 0)
        {
            SendClientMessage(playerid, COLOUR_GREY, "There was no numbers found with that name.");
        }
        mysql_free_result();
    return 1;
}



Re: How to set a variable to mysql_store_result? - [HiC]TheKiller - 29.01.2012

https://sampwiki.blast.hk/wiki/MySQL#mysql_fetch_field_row

Use that to fetch the value to use it in another query.


Re: How to set a variable to mysql_store_result? - Scenario - 29.01.2012

Would mysql_affected_rows() be an appropriate function for what you're trying to accomplish?