SA-MP Forums Archive
MySQL issues. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MySQL issues. (/showthread.php?tid=262136)



MySQL issues. - yanir3 - 16.06.2011

Hey, I recently started working with mySQL, I have a problem with my login system.
It's just not loading the stats.

PHP код:
forward LoadUser(playerid);
public 
LoadUser(playerid)
{
new 
query[256];
format(querysizeof(query),"SELECT * FROM playerinfo WHERE Name=%s",pName(playerid));
mysql_query(query);
mysql_store_result();
if(
mysql_num_rows())
if(
mysql_fetch_row_format(query,"|"))
{
        new 
field[13][MAX_PLAYER_NAME];
        
explode(queryfield"|");
        
mysql_free_result();
        
PlayerInfo[playerid][Money] = strval(field[3]);
        
PlayerInfo[playerid][Admin] = strval(field[4]);
        
PlayerInfo[playerid][Level] = strval(field[5]);
        
PlayerInfo[playerid][Bank] = strval(field[6]);
        
PlayerInfo[playerid][Kills] = strval(field[7]);
        
PlayerInfo[playerid][Deaths] = strval(field[8]);
        
PlayerInfo[playerid][Skin] = strval(field[9]);
        
PlayerInfo[playerid][Job] = strval(field[10]);
        
PlayerInfo[playerid][Watch] = strval(field[11]);
        
PlayerInfo[playerid][Notepad] = strval(field[12]);
}

I can't find the problem.. can someone help me please?


AW: MySQL issues. - xerox8521 - 16.06.2011

Quote:
Originally Posted by yanir3
Посмотреть сообщение
Hey, I recently started working with mySQL, I have a problem with my login system.
It's just not loading the stats.

pawn Код:
forward LoadUser(playerid);
public LoadUser(playerid)
{
new query[256];
format(query, sizeof(query),"SELECT * FROM playerinfo WHERE Name=%s",pName(playerid));
mysql_query(query);
mysql_store_result();
if(mysql_num_rows())
if(mysql_fetch_row_format(query,"|"))
{
        new field[13][MAX_PLAYER_NAME];
        explode(query, field, "|");
        mysql_free_result(); // This line must be under all other things you want to set
        PlayerInfo[playerid][Money] = strval(field[3]);
        PlayerInfo[playerid][Admin] = strval(field[4]);
        PlayerInfo[playerid][Level] = strval(field[5]);
        PlayerInfo[playerid][Bank] = strval(field[6]);
        PlayerInfo[playerid][Kills] = strval(field[7]);
        PlayerInfo[playerid][Deaths] = strval(field[8]);
        PlayerInfo[playerid][Skin] = strval(field[9]);
        PlayerInfo[playerid][Job] = strval(field[10]);
        PlayerInfo[playerid][Watch] = strval(field[11]);
        PlayerInfo[playerid][Notepad] = strval(field[12]);
}
}
I can't find the problem.. can someone help me please?
As you see above in the comment you free the result before you set anything put it under your last thing you want to get


Re: MySQL issues. - yanir3 - 16.06.2011

Tried using mysql_free_result in the end, still not workingn, I used explode to save the data.
Hmm, any other ideas to save the data?


AW: Re: MySQL issues. - xerox8521 - 16.06.2011

Quote:
Originally Posted by yanir3
Посмотреть сообщение
Tried using mysql_free_result in the end, still not workingn, I used explode to save the data.
Hmm, any other ideas to save the data?
which mysql plugin do you use ?


Re: MySQL issues. - yanir3 - 16.06.2011

g-stylez's one.
I use the same thing with my houses system and it works, can't figure out why this one isn't working.


AW: MySQL issues. - xerox8521 - 16.06.2011

This is how it works for me
pawn Код:
// somewhere at the top of your script
#define mysql_fetch_row(%1) mysql_fetch_row_format(%1,"|")

if(mysql_num_rows () != 0)
{
    new line[300];
    if(mysql_fetch_row(line)) //Fetches the line
    {
           new data[13];//The data strings
           new data2[21]; //The data variables
           sscanf(line, "p<|>ds[24]s[60]ddddddddddddddddddd",data2[1], data[1],data[2],data2[2],data2[3],data2[4],data2[5],data2[6],data2[7],data2[8],data2[9],data2[10],data2[11],data2[12],data2[13],data2[14],data2[15],data2[16],data2[17],data2[18],data2[19],data2[20]); //Splits the line with sscanf
           SetPlayerScore(playerid, data2[3]); //Sets players score
           GivePlayerMoney(playerid,data2[2]); // Gives player money
           PlayerInfo[playerid][AdminLevel] = data2[4]; //Sets players admin level
    }
               
}



Re: MySQL issues. - yanir3 - 17.06.2011

Still not working, it's not even reaching the
Quote:

new data[13];//The data strings

part, I think it's stopping before the if(mysql_num_rows..


Re: MySQL issues. - yanir3 - 19.06.2011

Anyone?


Re: MySQL issues. - Calgon - 19.06.2011

What is your code now that you've fixed the problem with mysql_free_result?