SA-MP Forums Archive
MySQL problem [EASY, ++REP] - 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: MySQL problem [EASY, ++REP] (/showthread.php?tid=577947)



MySQL problem [EASY, ++REP] - MarcGonzales - 15.06.2015

well, here it gets me arguement type mismatch

PHP код:
    if(dialogid == DIALOG_REGISTER)
    {
        if(
response)
        {
            if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD"Register""You should enter a password in order to continue""Register""Quit");
            new 
query[200], pName[MAX_PLAYER_NAME], tmp;
            
format(querysizeof(query), "SELECT id FROM accounts ORDER BY id DESC LIMIT 1");
            
mysql_query(query);
            
mysql_store_result();
            while(
mysql_fetch_row_format(query"|"))
            {
                
mysql_get_field("id"tmp);
                
strval(tmp);
                
tmp tmp 1;
            }
            
mysql_free_result();
            
GetPlayerName(playeridpNamesizeof(pName));
            
format(querysizeof(query), "INSERT INTO accounts(id, name, password) VALUES ('%i', '%s','%s')"tmppNameinputtext);
            
mysql_query(query);
            
SendClientMessage(playerid, -1"You have been registered");
        } 



Re: MySQL problem [EASY, ++REP] - MarcGonzales - 15.06.2015

to make it easier, can I get something outside of mysql database(table) and use it generally in coding?

if it needs sscanf, please tell me how

Like that ID example


Re: MySQL problem [EASY, ++REP] - Vince - 15.06.2015

Ugh, just use auto increment. And hash the passwords. And never use user input in a query without sanitizing it.


Re: MySQL problem [EASY, ++REP] - mamorunl - 15.06.2015

You are getting a tag mismatch exception on 20 rows of code? Specify your row and don't let people guess.


Re: MySQL problem [EASY, ++REP] - MarcGonzales - 15.06.2015

Quote:
Originally Posted by mamorunl
Посмотреть сообщение
You are getting a tag mismatch exception on 20 rows of code? Specify your row and don't let people guess.
mysql_get_field("id", tmp);


Re: MySQL problem [EASY, ++REP] - Konstantinos - 15.06.2015

The second parameter must have been a string instead of an integer.

But.. do what Vince said, plus I suggest you to learn how to use threaded queries and update to R39-3.