[Question] MySQL Plugin
#1

I have a command that needs a name of a player with underscores (e.g. John_Doe) and would update records in the database if the user exists. My problem is, that whenever it INSERTS or UPDATES data, it get rids of the underscore from the name.

So for example:
A player types "/pay John_Doe 5000"

Here's what the MySQL function actually does:
Код:
CMySQLHandler::Query(UPDATE accounts SET money=money+'5000' WHERE username='John Doe') - Successfully executed.
With the example given, you would see that the underscore from the name was removed. This was taken from an actual debug text file of the MySQL plugin.

Any thoughts on this?
Reply
#2

Try adding the \_ for it is originated for php, meybe it will work if you add an \ before the underscore.

Note: Use the split function.
Example:
pawn Код:
new Name[2][MAX_PLAYER_NAME];
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
split(PlayerName, Name, "_");
format(PlayerName, 100, "%s\\_%s", Name[0], Name[1]);
Reply
#3

That's a good suggestion. But it's weird since I've already used those functions a lot of times having data with underscores and worked perfectly. Anyway, I just used the strreplace function by replacing the spaces with underscores. Thanks though.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)