If inputtext is empty, it will crash the server and you don't escape the strings.
Anyway, it is really simple. Modify the code to match the table's and columns' name as we can't possible guess your code and display a dialog with input style. On its response:
PHP код:
if (response)
{
if (!inputtext[0])
{
SendClientMessage(playerid, -1, "Error: Input a name.");
ShowPlayerDialog(...);
return 1;
}
new p_name[MAX_PLAYER_NAME];
GetPlayerName(playerid, p_name, MAX_PLAYER_NAME);
switch (SetPlayerName(playerid, inputtext))
{
case 1:
{
new Query[100];
mysql_format(connection_handle_here, Query, sizeof Query, "UPDATE users SET name='%e' WHERE name='%e' LIMIT 1", inputtext, p_name);
mysql_tquery(connection_handle_here, Query, "", "");
SendClientMessage(playerid, -1, "Name was changed successfully.");
}
case 0: SendClientMessage(playerid, -1, "Error: Your currently name is the same.");
case -1: SendClientMessage(playerid, -1, "Error: The name cannot be changed (it's already in use, too long or has invalid characters).");
}
return 1;
}
If you don't know about the dialogs, read:
https://sampwiki.blast.hk/wiki/ShowPlayerDialog and
https://sampwiki.blast.hk/wiki/OnDialogResponse
And don't expect a working code for just copy-paste, you SHOULD try an attempt yourself.