Help please MySQL R34
#1

PHP код:
GetAccountID(playerid)
{
    
GetPlayerName(playeridsnsizeof(sn));
    
format(query128,"SELECT ID FROM "TABLE_ACCOUNT" WHERE Name = '%s'"sn);
    
mysql_tquery(1query"""");
    
mysql_store_result();
    if(
mysql_num_rows() == 1)
    {
        
PlayerInfo[playerid][pID] = mysql_fetch_int();
        
mysql_free_result();
        return 
PlayerInfo[playerid][pID];
    }
    return 
0;

PHP код:
error 017undefined symbol "mysql_fetch_int" 
Код:
PHP код:
PlayerInfo[playerid][pID] = mysql_fetch_int(); 
Help please
Reply
#2

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.
Reply
#3

Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
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.

Give please correction code?
Reply
#4

pawn Код:
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;
}
Reply
#5

To me spoke to replace:
mysql_query ();
On:
mysql_tquery (1, query, """ ",);

I have replaced, now at me "Registration of the new character" accounts do not remain, what is the matter? O_O
Transferred from MySQL R5 on MySQL R34
Reply
#6

Just replace your posted code by the code I gave you, it should work properly as I have nearly identical code in my script.
Reply
#7

Does not work nevertheless.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)