mysql saving
#1

Код:
case DIALOG_FORUMNAME:
  		{
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_FORUMNAME , DIALOG_STYLE_INPUT, "Forumname", "Te rugam introdu-ti numele de pe forum mai jos.", "Enter", "Cancel");
                new string[64];
                
                GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
				mysql_real_escape_string(szPlayerName, szPlayerName);

				format(szLargeString, sizeof(szLargeString), "INSERT INTO playeraccounts (forumname) VALUES('%s')", inputtext);
				mysql_tquery(handle, szLargeString);
				SCM(playerid, COLOR_GREEN, "Ti-ai setat forumname-ul.");
            }
		}
This is the dialog for /forumname but if he use it again it will add another row?
How to make to update the actual row if he already set his username?
Reply
#2

What do you store in the table "playeraccounts"?
Reply
#3

http://dev.mysql.com/doc/refman/5.7/en/update.html
Reply
#4

format(szLargeString, sizeof(szLargeString), "UPDATE `playeraccounts` SET `forumname` = '%s' WHERE `playername` = '%s'", szPlayerName,name);

Use UPDATE function.
Also see where I set bold, NEVER forget to use mysql_real_escape_string made string in the queries.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)