Register half name in mySQL
#1

When I register the name "max" the server log puts "ax".

Code:
[10:29:52] [INFO] query "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `personalmsg`, `Admin`,`Money`) VALUES ('ax', 'DC587CD2F91B38336043F2ACF2CAA710AF0DE5604D8AE3B08049985A18EB615AB63BBC1B748884CA48CDDCF31F83FF37050E02AE0DD986C212B9C700EA857B6C', '92.168.0.150', 'New Player', 0,'0')" successfully executed within 345.85 milliseconds
[10:29:52] [DEBUG] CResultSet::Create(connection=0x8916b8, query_str='INSERT INTO `accounts` (`Name`, `Password`, `IP`, `personalmsg`, `Admin`,`Money`) VALUES ('ax', 'DC587CD2F91B38336043F2ACF2CAA710AF0DE5604D8AE3B08049985A18EB615AB63BBC1B748884CA48CDDCF31F83FF37050E02AE0DD986C212B9C700EA857B6C', '92.168.0.150', 'New Player', 0,'0')')

Code:
    new query[300], name[300], playerip[16];
            GetPlayerName(playerid, name, sizeof(name));
            GetPlayerIp(playerid, playerip, sizeof(playerip));
            format(PlayerInfo[playerid][personalmsg], 128, "%s", "New Player");
            WP_Hash(PlayerInfo[playerid][Password], 129, inputtext);
            mysql_format(MySQL, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `personalmsg`, `Admin`,`Money`) VALUES ('%e', '%e', '%e', '%e', 0,'%d')", name[playerid], PlayerInfo[playerid][Password], playerip[playerid], PlayerInfo[playerid][personalmsg], PlayerInfo[playerid][Money]);
            printf(query);
I don't have any error. just incorrect codes.
Reply
#2

Code:
..... VALUES ('%e', '%e', '%e', '%e', 0,'%d')", name[playerid], ......
That in the red is your problem. You are accessing the array from a given index, in this case: player's id, which is zero. So it will return everything after the first character.
simply change name[playerid] to name.

Edit: Also I would suggest to lower the size of name from 300 to MAX_PLAYER_NAME which by default is 24.
Reply
#3

Quote:
Originally Posted by bgedition
View Post
Code:
..... VALUES ('%e', '%e', '%e', '%e', 0,'%d')", name[playerid], ......
That in the red is your problem. You are accessing the array from a given index, in this case: player's id, which is zero. So it will return everything after the first character.
simply change name[playerid] to name.
Right, Thank you it worked REP.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)