mysql (strickenKid) wont load data -
CounterTerroristUnit - 01.09.2011
hi,
saving on disconnect and registring works fine and is inserted into the right table but as soon as a already registered player trys to log in it fails.
Well, the password also works, cause when i enter the right password on login it says login successful and it proceeds.
But it fails when it comes to the other data.
The log says:
Код:
mysql_fetch_field could not find field name "NULL".
This is the code:
pawn Код:
new query[1400], pname[24], savingstring[1400];
GetPlayerName(playerid, pname, 24);
format(query, sizeof(query), "SELECT Score, Money, Kills, Deaths, Admin FROM Users WHERE name = '%s'", pname);
mysql_query(query);
mysql_store_result();
mysql_fetch_row(query,"|");
{
mysql_fetch_field(savingstring, "Score"); SetPlayerScore(playerid, strval(savingstring));
mysql_fetch_field(savingstring, "Money"); MoneyCash[playerid] = strval(savingstring);
mysql_fetch_field(savingstring, "Kills"); kills[playerid] = strval(savingstring);
mysql_fetch_field(savingstring, "Deaths"); deaths[playerid] = strval(savingstring);
mysql_fetch_field(savingstring, "Admin"); Player[playerid][AdminLevel] = strval(savingstring);
//...
}
mysql_free_result();
help would be great
//edit: +Reps for people that help me
Re: mysql (strickenKid) wont load data -
[MWR]Blood - 01.09.2011
You could use sscanf to store the data, a lot easier!
Re: mysql (strickenKid) wont load data -
CounterTerroristUnit - 01.09.2011
could u give me an example pls
Re: mysql (strickenKid) wont load data -
[MWR]Blood - 01.09.2011
Taken from my script.
pawn Код:
stock LoadStats(playerid)
{
format(Query, sizeof(Query), "SELECT FROM `YOUR_TABLE_HERE` WHERE `Username` = '%s'", GetPName(playerid));
mysql_query(Query);
mysql_store_result();
mysql_fetch_row_format(Query, "|");
sscanf(Query, "e<p<|>ds[23]s[30]s[16]iiiiiiiiiiiii>", PInfo[playerid]);//the MySQL table structure, in the order how it is
mysql_free_result();
return 1;
}
Re: mysql (strickenKid) wont load data -
CounterTerroristUnit - 01.09.2011
thx alot could u also show me the part of ur script where u check the players entered password pls?
would be great.
Re: mysql (strickenKid) wont load data -
Joe Staff - 01.09.2011
Also you didn't set "savestring" to anything.
Edit: nevermind, lol. I haven't worked with SQL in a while
Re: mysql (strickenKid) wont load data -
CounterTerroristUnit - 01.09.2011
mhh im kinda new to mysql so i need ur help guys
i got this error messages printed in the server logs:
Код:
[00:12:03] [MySQL] Error (0): Failed to exeute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM `Users` WHERE `name` = 'TestPlayer'' at line 1.
[00:12:03] [MySQL] Error (0): Function: mysql_store_result called when no prior successful query executed. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM `Users` WHERE `name` = 'TestPlayer'' at line 1.
[00:12:03] [MySQL] Error (0): Function: mysql_store_result called when no result stored. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM `Users` WHERE `name` = 'TestPlayer'' at line 1.
[00:12:17] [MySQL] Error (0): Failed to exeute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM `Users` WHERE `name` = 'TestPlayer'' at line 1.
[00:12:17] [MySQL] Error (0): Function: mysql_store_result called when no prior successful query executed. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM `Users` WHERE `name` = 'TestPlayer'' at line 1.
[00:12:17] [MySQL] Error (0): Function: mysql_store_result called when no result stored. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM `Users` WHERE `name` = 'TestPlayer'' at line 1.
this is the pawno part:
pawn Код:
new Query[1400], pname[24];
GetPlayerName(playerid, pname, 24);
format(Query, sizeof(Query), "SELECT FROM `Users` WHERE `name` = '%s'", pname);
mysql_query(Query);
mysql_store_result();
mysql_fetch_row(Query, "|");
sscanf(Query, "ddd",MoneyVar[playerid],kills[playerid],deaths[playerid]);
mysql_free_result();
so can u tell me why i keep getting this errors?
Would be very happy to be able to give u guys some Reps+
and also when i spawn i get no money or kills loaded from the file it thinks im a new player without any score.
Re: mysql (strickenKid) wont load data -
iggy1 - 01.09.2011
Try this
pawn Код:
format(Query, sizeof(Query), "SELECT * FROM `Users` WHERE `name` = '%s'", pname);
You wasn't selecting any data.
EDIT: Oh and change this too.
pawn Код:
sscanf(Query, "p<|>ddd",MoneyVar[playerid],kills[playerid],deaths[playerid]);
Re: mysql (strickenKid) wont load data -
CounterTerroristUnit - 01.09.2011
thx alot iggy

no more log errors
but theres still a problem...
//edit: nvm, its fixed.
login works now but i dont receive the money after login.
Are u sure i dont need to add more to this? :
pawn Код:
new Query[1400], pname[24];
GetPlayerName(playerid, pname, 24);
format(Query, sizeof(Query), "SELECT * FROM `Users` WHERE `name` = '%s'", pname);
mysql_query(Query);
mysql_store_result();
mysql_fetch_row(Query, "|");
sscanf(Query, "p<|>dddd",SetPlayerScore(playerid),MoneyVar[playerid],kills[playerid],deaths[playerid]);
mysql_free_result();
is that really all i need to do to load my saved stats?
Also i dont know how to load the score, so help would be much appreciated.