SA-MP Forums Archive
[MYSQL] Rank saving problem. - 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] Rank saving problem. (/showthread.php?tid=396338)



[MYSQL] Rank saving problem. - tiernantheman - 30.11.2012

Hey guys, I'm having a problem with faction ranks saving. Basically what happens is I type /editranks and when I change the name, it changes the name in game, but it dosen't update/change it on the mysql database in phpmyadmin. It pretty much does this for all ranks, here is what one of the ranks coding is like its all the same just a different rank.

pawn Код:
case DIALOG_RANK2:
{
    new query[400];
    format(Factions[PlayerInfo[playerid][Faction]][Rank2], MAX_PLAYER_NAME, "%s", inputtext);
    format(query, sizeof(query), "UPDATE Factions SET Rank2 = '%s' WHERE ID ='%d'", inputtext, PlayerInfo[playerid][Faction]);
    mysql_query(query);
}
Any help is appreciated, thanks.


Re: [MYSQL] Rank saving problem. - Vince - 30.11.2012

Ew, ew, raw user input inserted into a query! Very prone to SQL injection!

Post mysql_log.


Re: [MYSQL] Rank saving problem. - Djole1337 - 30.11.2012

- deleted


Re: [MYSQL] Rank saving problem. - tiernantheman - 30.11.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
Ew, ew, raw user input inserted into a query! Very prone to SQL injection!

Post mysql_log.
Hahaha.

This is what it shows when I actually change the rank, it only changes it in game, but not in the database like I said :P. Log:

Код:
[15:05:55] >> mysql_query( Connection handle: 1 )

[15:05:55] CMySQLHandler::Query(UPDATE Factions SET Rank = 'Cadet Test' WHERE ID ='1') - An error has occured. (Error ID: 1054, Unknown column 'ID' in 'where clause')



Re: [MYSQL] Rank saving problem. - JJones432 - 30.11.2012

Do you actually have a column named "ID"?


Re: [MYSQL] Rank saving problem. - tiernantheman - 30.11.2012

Quote:
Originally Posted by JJones432
Посмотреть сообщение
Do you actually have a column named "ID"?
Not ID, but there is one called SQLID.


Re: [MYSQL] Rank saving problem. - InfiniTy. - 30.11.2012

pawn Код:
case DIALOG_RANK2:
{
    new query[400];
    format(Factions[PlayerInfo[playerid][Faction]][Rank2], MAX_PLAYER_NAME, "%s", inputtext);
    format(query, sizeof(query), "UPDATE Factions SET Rank2 = '%s' WHERE ID = %d", inputtext, PlayerInfo[playerid][Faction]);
    mysql_query(query);
}
Edit: If the column is named SQLID then instead of ID put SQLID


Re: [MYSQL] Rank saving problem. - tiernantheman - 30.11.2012

Quote:
Originally Posted by Adytza.
Посмотреть сообщение
pawn Код:
case DIALOG_RANK2:
{
    new query[400];
    format(Factions[PlayerInfo[playerid][Faction]][Rank2], MAX_PLAYER_NAME, "%s", inputtext);
    format(query, sizeof(query), "UPDATE Factions SET Rank2 = '%s' WHERE ID = %d", inputtext, PlayerInfo[playerid][Faction]);
    mysql_query(query);
}
Edit: If the column is named SQLID then instead of ID put SQLID
That worked, thanks. Thanks to all who helped