Please help with Mysql data load
#1

Hi, I have mysql data loading problem. Code:
Quote:

forward MysqlLoad(playerid);
public MysqlLoad(playerid)
{
new query[100], pname[MAX_PLAYER_NAME], savingstring[50];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
format(query,sizeof(query),"SELECT Pinigai, Patirtis, PosX, PosY, PosZ, PosA, Naujokas, Lytis FROM pinfo WHERE Name = '%s'",pname);
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(savingstring, "Pinigai"); PlayerInfo[playerid][Pinigai] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Patirtis"); PlayerInfo[playerid][Patirtis] = strval(savingstring);
mysql_fetch_field_row(savingstring, "PosX"); PlayerInfo[playerid][PosX] = strval(savingstring);
mysql_fetch_field_row(savingstring, "PosY"); PlayerInfo[playerid][PosY] = strval(savingstring);
mysql_fetch_field_row(savingstring, "PosZ"); PlayerInfo[playerid][PosZ] = strval(savingstring);
mysql_fetch_field_row(savingstring, "PosA"); PlayerInfo[playerid][PosA] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Naujokas"); PlayerInfo[playerid][Naujokas] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Lytis"); PlayerInfo[playerid][Lytis] = strval(savingstring);
}
mysql_free_result();
}

and here i load data(here only to the position of stacking):
Quote:

public OnPlayerSpawn(playerid)
{
if(Death[playerid] == 1)
{
SetPlayerPos(playerid, -197.3941,-1770.4453,675.7687);
SetPlayerInterior(playerid, 3);
Death[playerid] = 0;
}
else
{
SetPlayerPos(playerid, PlayerInfo[playerid][PosX],PlayerInfo[playerid][PosY],PlayerInfo[playerid][PosZ]);
SetPlayerFacingAngle(playerid, PlayerInfo[playerid][PosA]);
}
return 1;
}

but code does not work no pawno errors
I would be grateful for the help.
Sorry for my bad English, I live in Lithaunia.
Reply
#2

You don't select database from where to load.

LTU: Nepasirenki duomenu bazes is kurios pakraut visus kintamuosius.Ir speju server.log yra pilna error.
Reply
#3

to make it easier, you can just do
pawn Код:
format(query,sizeof(query),"SELECT * FROM pinfo WHERE Name = '%s'",pname);
You should also use %e instead of %s. Also, consider using a newer version of mysql. Check your mysql log (its a text file) and paste any errors here as well. If it's a syntax error, mysql will give it in the log, instead of the compiler.
Reply
#4

Thaks you for help. It's work!
Reply
#5

pawn Код:
new query[100], pname[MAX_PLAYER_NAME], savingstring[50];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
format(query,sizeof(query),"SELECT Pinigai, Patirtis, PosX, PosY, PosZ, PosA, Naujokas, Lytis FROM pinfo WHERE Name = '%s'",pname);
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(savingstring, "Pinigai"); PlayerInfo[playerid][Pinigai] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Patirtis"); PlayerInfo[playerid][Patirtis] = strval(savingstring);
mysql_fetch_field_row(savingstring, "PosX"); PlayerInfo[playerid][PosX] = strval(savingstring);
mysql_fetch_field_row(savingstring, "PosY"); PlayerInfo[playerid][PosY] = strval(savingstring);
mysql_fetch_field_row(savingstring, "PosZ"); PlayerInfo[playerid][PosZ] = strval(savingstring);
mysql_fetch_field_row(savingstring, "PosA"); PlayerInfo[playerid][PosA] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Naujokas"); PlayerInfo[playerid][Naujokas] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Lytis"); PlayerInfo[playerid][Lytis] = strval(savingstring);
This is just... WRONG tho.
Reply
#6

Quote:
Originally Posted by Runn3R
Посмотреть сообщение
pawn Код:
new query[100], pname[MAX_PLAYER_NAME], savingstring[50];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
format(query,sizeof(query),"SELECT Pinigai, Patirtis, PosX, PosY, PosZ, PosA, Naujokas, Lytis FROM pinfo WHERE Name = '%s'",pname);
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(savingstring, "Pinigai"); PlayerInfo[playerid][Pinigai] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Patirtis"); PlayerInfo[playerid][Patirtis] = strval(savingstring);
mysql_fetch_field_row(savingstring, "PosX"); PlayerInfo[playerid][PosX] = strval(savingstring);
mysql_fetch_field_row(savingstring, "PosY"); PlayerInfo[playerid][PosY] = strval(savingstring);
mysql_fetch_field_row(savingstring, "PosZ"); PlayerInfo[playerid][PosZ] = strval(savingstring);
mysql_fetch_field_row(savingstring, "PosA"); PlayerInfo[playerid][PosA] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Naujokas"); PlayerInfo[playerid][Naujokas] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Lytis"); PlayerInfo[playerid][Lytis] = strval(savingstring);
This is just... WRONG tho.
What about it is wrong? From what I see, that code would work perfectly fine.
Reply
#7

Quote:
Originally Posted by TakeiT
Посмотреть сообщение
What about it is wrong? From what I see, that code would work perfectly fine.
You must be blind then.

pawn Код:
new savingstring[50];
mysql_fetch_field_row(savingstring, "PosX"); PlayerInfo[playerid][PosX] = strval(savingstring);
Why just don't do it like this?

pawn Код:
mysql_fetch_field_row(PlayerInfo[playerid][PosX], "PosX");
LOL?
Reply
#8

Quote:
Originally Posted by Runn3R
Посмотреть сообщение
You must be blind then.

pawn Код:
new savingstring[50];
mysql_fetch_field_row(savingstring, "PosX"); PlayerInfo[playerid][PosX] = strval(savingstring);
Why just don't do it like this?

pawn Код:
mysql_fetch_field_row(PlayerInfo[playerid][PosX], "PosX");
LOL?
Other method should still work regardless. That is a very common method in the old way of MySQL, back in R6...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)