GetAccountID(playerid)
{
GetPlayerName(playerid, sn, sizeof(sn));
format(query, 128,"SELECT ID FROM "TABLE_ACCOUNT" WHERE Name = '%s'", sn);
mysql_tquery(1, query, "", "");
mysql_store_result();
if(mysql_num_rows() == 1)
{
PlayerInfo[playerid][pID] = mysql_fetch_int();
mysql_free_result();
return PlayerInfo[playerid][pID];
}
return 0;
}
error 017: undefined symbol "mysql_fetch_int"
PlayerInfo[playerid][pID] = mysql_fetch_int();
In R34, there is no function called "mysql_fetch_int".
Also, you're using a tquery which is used for threaded queries. For SELECT queries, you need to specify a callback. That callback will be called, where you can access the data using the cache_* functions. Your code is mixing up threaded queries with unthreaded code to get the data. |
GetAccountID(playerid)
{
// Setup local variables
new query[128], sn[24];
// Get playername
GetPlayerName(playerid, sn, sizeof(sn));
// Format the query to get the ID from the player's account (limit the amount of rows to 1 to prevent MySQL searching through the entire database)
format(query, 128,"SELECT ID FROM "TABLE_ACCOUNT" WHERE Name = '%s' LIMIT 1", sn);
// Execute the threaded query and call the callback "OnAccountIDLoad" with "playerid" as parameter when MySQL finished executing the query
mysql_tquery(1, query, "OnAccountIDLoad", "i", playerid);
return 0;
}
// This callback is called by MySQL when the query has finished execution
forward OnAccountIDLoad(playerid);
public OnAccountIDLoad(playerid)
{
// Check if there was a result
if (cache_get_row_count() == 1)
{
// Get the contents of the "ID" field as an integer (from row 0) and store it
PlayerInfo[playerid][pID] = cache_get_field_content_int(0, "ID");
}
// Clear the cache-data upon exiting this callback
return 1;
}