MySQL help -
V_LOPE - 01.12.2012
Well, I got problem saving nickname in database for some reason
pawn Код:
new query[200], IP[16];
GetPlayerIp(playerid, IP, 16);
format(query, sizeof(query), "INSERT INTO accounts (UserName, Password,kills, deaths, Rank, Level, Operator, TagAllowed, dRank, Score, PrestigeWeaponID1,PrestigeWeaponID2,PrestigeWeaponID3,PrestigeWeaponID4) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0)", PlayerName2(playerid), passwordstring);
mysql_query(query);
format(query, sizeof(query), "INSERT INTO accounts (CapturedZones,PistolSkills,SicPistolSkill,DeserteagleSkill,Shotgun,CombatShotgun,UziTec,Mp5,ak47,m4,Sniper,LastPromotionsDay,LastPromotionsMonth,LastPromotionsYear) VALUES(0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0)");
mysql_query(query);
format(query, sizeof(query), "INSERT INTO accounts (HiredDay, HiredMonth, HiredYear, CM, SiM, Money, IP) VALUES(0, 0, 0, 0, 0, 0,'%s')",IP);
mysql_query(query);
//We do not need to store or free a result as it
//is not a select statement. We can now send the
//client a registration success message and set the
//Login variable to 1.
SendClientMessage(playerid, -1, "You have been registered on this server!");
PlayerInfo[playerid][LoggedIn] = 1;
everythings saved.
but nickname not.
NOTE: UserName = VARCHAR(24)
Re: MySQL help - Jarnu - 01.12.2012
Why you queried that 3 times? ..
Simply do a one big query, then try. and to save nicks use mysql_real_escapestring
Example:
pawn Код:
stock escpname(playerid)
{
new escname[24], Pname[24];
GetPlayerName(playerid, Pname, 24);
mysql_real_escape_string(Pname, escname);
return escname;
}
change PlayerName2 to escpname
Re: MySQL help -
ReneG - 01.12.2012
Quote:
Originally Posted by Jarnu
Why you queried that 3 times? ..
Simply do a one big query, then try. and to save nicks use mysql_real_escapestring
Example:
pawn Код:
stock escpname(playerid) { new escname[24], Pname[24]; GetPlayerName(playerid, Pname, 24); mysql_real_escape_string(Pname, escname); return escname; }
change PlayerName2 to escpname
|
sa-mp nicks only allow characters
Код:
0-9 a-z [] () $ @ . =
since quotes aren't allowed, it's kind of pointless to escape a username.
@OP, whenever you're having trouble with MySQL, enable debugging and read the mysql_log.txt. Or just print the query and see what's wrong with it.
Re: MySQL help -
V_LOPE - 01.12.2012
Quote:
Originally Posted by Jarnu
Why you queried that 3 times? ..
Simply do a one big query, then try. and to save nicks use mysql_real_escapestring
Example:
pawn Код:
stock escpname(playerid) { new escname[24], Pname[24]; GetPlayerName(playerid, Pname, 24); mysql_real_escape_string(Pname, escname); return escname; }
change PlayerName2 to escpname
|
didn't worked.
Re: MySQL help -
ViruZz - 01.12.2012
Here you go
pawn Код:
new query[200], IP[16], playername[MAX_PLAYER_NAME];
GetPlayerIp(playerid, IP, 16);
format(query, sizeof(query), "INSERT INTO accounts (UserName, Password,kills, deaths, Rank, Level, Operator, TagAllowed, dRank, Score, PrestigeWeaponID1,PrestigeWeaponID2,PrestigeWeaponID3,PrestigeWeaponID4) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0)", GetPlayerName(playerid, playername, MAX_PLAYER_NAME), passwordstring);
mysql_query(query);
format(query, sizeof(query), "INSERT INTO accounts (CapturedZones,PistolSkills,SicPistolSkill,DeserteagleSkill,Shotgun,CombatShotgun,UziTec,Mp5,ak47,m4,Sniper,LastPromotionsDay,LastPromotionsMonth,LastPromotionsYear) VALUES(0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0)");
mysql_query(query);
format(query, sizeof(query), "INSERT INTO accounts (HiredDay, HiredMonth, HiredYear, CM, SiM, Money, IP) VALUES(0, 0, 0, 0, 0, 0,'%s')",IP);
mysql_query(query);
//We do not need to store or free a result as it
//is not a select statement. We can now send the
//client a registration success message and set the
//Login variable to 1.
SendClientMessage(playerid, -1, "You have been registered on this server!");
PlayerInfo[playerid][LoggedIn] = 1;
Re: MySQL help -
V_LOPE - 01.12.2012
Quote:
Originally Posted by ViruZz
Here you go
pawn Код:
new query[200], IP[16], playername[MAX_PLAYER_NAME]; GetPlayerIp(playerid, IP, 16); format(query, sizeof(query), "INSERT INTO accounts (UserName, Password,kills, deaths, Rank, Level, Operator, TagAllowed, dRank, Score, PrestigeWeaponID1,PrestigeWeaponID2,PrestigeWeaponID3,PrestigeWeaponID4) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0)", GetPlayerName(playerid, playername, MAX_PLAYER_NAME), passwordstring); mysql_query(query); format(query, sizeof(query), "INSERT INTO accounts (CapturedZones,PistolSkills,SicPistolSkill,DeserteagleSkill,Shotgun,CombatShotgun,UziTec,Mp5,ak47,m4,Sniper,LastPromotionsDay,LastPromotionsMonth,LastPromotionsYear) VALUES(0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0)"); mysql_query(query); format(query, sizeof(query), "INSERT INTO accounts (HiredDay, HiredMonth, HiredYear, CM, SiM, Money, IP) VALUES(0, 0, 0, 0, 0, 0,'%s')",IP); mysql_query(query); //We do not need to store or free a result as it //is not a select statement. We can now send the //client a registration success message and set the //Login variable to 1. SendClientMessage(playerid, -1, "You have been registered on this server!"); PlayerInfo[playerid][LoggedIn] = 1;
|
what did you change?
same as PlayerName2(playerid) -.-
Re: MySQL help -
ViruZz - 01.12.2012
Quote:
Originally Posted by V_LOPE
what did you change?
same as PlayerName2(playerid) -.-
|
I advise you to save to the player names directly from the GetPlayerName function then a custom one. If your problem still occurs then its a problem in your MySQL columns
Re: MySQL help -
V_LOPE - 01.12.2012
Quote:
Originally Posted by ViruZz
If your problem still occurs then its a problem in your MySQL columns
|
Name Type Length/Values1
UserName| Varchar / 24
Re: MySQL help -
V_LOPE - 01.12.2012
Bump.
Re: MySQL help -
Vince - 01.12.2012
Set default values on your columns. You're only inserting 3 new variables.