Take information from mysql
#1

I need to take somthing from MYSQL, for example, i need take a field which calls "keycar" and i need only this.
how i can take it ? somthing like this: SELECT blablabla WHERE user = %s
and i need to put it on other field.
Reply
#2

Example:
pawn Code:
public OnPlayerConnect(playerid)
{
    new
        value,
        name[24],
        query[79],
        field[12];
       
    GetPlayerName(playerid, name, sizeof(name)); // we need the name of the player to make the query
    format(query, sizeof(query), "SELECT keycar FROM players WHERE Nickname = '%s' LIMIT 1", name); // we format "query"
    // it means it will look for the content of "keycar" in the table "players" where the nickname is the name of the player,
    // LIMIT 1 means it will only take the first value
    mysql_query(query); // we make the query with "query" ("SELECT keycar FROM blablabla")
    mysql_store_result(); // we store the result of the query
    if(mysql_num_rows() > 0) // if theres any value then:
    {
        mysql_fetch_row_format(field); // fetch the value to the string "field"
        value = strval(field); // convert the string to an integer
    }
    mysql_free_result(); // free the mysql memory
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)