SA-MP Forums Archive
Help please MySQL R34 - 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: Help please MySQL R34 (/showthread.php?tid=492314)



Help please MySQL R34 - Size - 03.02.2014

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


Re: Help please MySQL R34 - PowerPC603 - 03.02.2014

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.


Re: Help please MySQL R34 - Size - 03.02.2014

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?



Re: Help please MySQL R34 - PowerPC603 - 03.02.2014

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;
}



Re: Help please MySQL R34 - Size - 03.02.2014

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


Re: Help please MySQL R34 - PowerPC603 - 03.02.2014

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


Re: Help please MySQL R34 - Size - 03.02.2014

Does not work nevertheless.