13.10.2012, 12:58
Follow the tutorial, as simple as that.
1. Format the query. Keep in mind that any user input should be escaped prior to querying. In your case, escape the password (either use mysql_format with the %e specifier or mysql_real_escape_string prior to format). I suggest adding a LIMIT clause to your query.
2. Execute it using mysql_function_query, specify a callback that will be fired when the query finishes. Also pass on the player ID to the callback.
3. Jump out of your current function and create a new callback.
4. See if the query returned any rows.
5. Grab the data returned by the query. I suggest you read this post.
Good luck.
1. Format the query. Keep in mind that any user input should be escaped prior to querying. In your case, escape the password (either use mysql_format with the %e specifier or mysql_real_escape_string prior to format). I suggest adding a LIMIT clause to your query.
2. Execute it using mysql_function_query, specify a callback that will be fired when the query finishes. Also pass on the player ID to the callback.
pawn Код:
mysql_function_query(dbHandle, query, true, "OnUserDataLoad", "i", playerid);
pawn Код:
forward OnUserDataLoad(playerid);
public OnUserDataLoad(playerid)
{
// This callback is fired once the query is finished!
}
pawn Код:
// In the new callback
new rows, fields;
cache_get_data(rows, fields);
if(rows)
{
// The query returned a row!
}
else
{
// The query returned nothing!
}
pawn Код:
if(rows)
{
new temp[64];
cache_get_row(0, 0, temp);
printf("First field data: %s", temp);
cache_get_row(0, 1, temp);
printf("Second field data: %s", temp);
cache_get_row(0, 7, temp);
printf("Eight field data: %s", temp);
}