28.11.2010, 10:06
The problem is in your syntax, not in the MySQL check.
Also what's the need for select *? You don't need to use any of the information in the columns, so there's no reason to select it all, if you have a lot of columns this may induce performance issues on the server.
Edit: Too late , anyway the select * stuff still applies
pawn Код:
dcmd_register(playerid,params[])
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
new Query[200], Pname[24], escpname[24];
GetPlayerName(playerid, Pname, 24);
mysql_real_escape_string(Pname, escpname);
format(Query, sizeof(Query), "SELECT user FROM `playerinfo` WHERE `user` = '%s'", escpname);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() != 0) return SendClientMessage(playerid,COLOUR_RED,"This account name is already in use!"); // I tried with this, but it wont work, i was logged in but i can just keep register a new account.
else
{
new PIP[50],pass[128];
GetPlayerName(playerid, Pname, 24);
new escpass[100];
if(sscanf(params,"s",pass)) return SendClientMessage(playerid,COLOUR_RED,"Usage: /register [Password]");
mysql_real_escape_string(pass, escpass);
mysql_real_escape_string(Pname, escpname);
GetPlayerIp(playerid, PIP, 50);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `score` = '%d',`money` = '%d' WHERE `user` = '%s'", GetPlayerScore(playerid), GetPlayerMoney(playerid), escpname);
mysql_query(Query);
GameTextForPlayer(playerid, "~g~Registered", 2000, 3);
SendClientMessage(playerid, 0x0000D9AA, "Registered and Logged into your account!");
SetPVarInt(playerid, "Logged", 1);
}
return 1;
}
Edit: Too late , anyway the select * stuff still applies