Getting String From Mysql Database
#1

Hello! like title says i want to load string from database , but my version doesn't work.

I Am Using pvars for this:

pawn Код:
new query[300], pname[24], savingstring[20],savingstring2[50];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT skoor, raha, admin, sugu, vanus, vaatamisi, registriaeg FROM kasutajad WHERE kasutajanimi = '%s'", pname);
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_row_format(query,"|"))
    {
        mysql_fetch_field_row(savingstring, "skoor"); SetPlayerScore(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "raha"); MoneyGiven[playerid] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "admin"); SetPVarInt(playerid, "Admin",strval(savingstring));
        mysql_fetch_field_row(savingstring, "sugu"); SetPVarInt(playerid, "Sugu",strval(savingstring));
        mysql_fetch_field_row(savingstring, "vanus"); SetPVarInt(playerid, "Vanus",strval(savingstring));
        mysql_fetch_field_row(savingstring, "vaatamisi"); SetPVarInt(playerid, "Vaatamisi",strval(savingstring));
        mysql_fetch_field_row(savingstring2, "registriaeg"); SetPVarString(playerid,"RegDate",savingstring2);
    }
There is something wrong with this line:
pawn Код:
mysql_fetch_field_row(savingstring2, "registriaeg"); SetPVarString(playerid,"RegDate",savingstring2);
but it wont load it. shows empty string, can someone help :P?
Reply
#2

If your using G-sTyLeZzZ plugin the put the following code in OnGameModeInit, to see what the query is returning and if there are any problems.

pawn Код:
mysql_debug(1);
It may or may not help. A file called "debug" will be created in the server directory.
Reply
#3

no im not using. and wrong is not mysql my problem is at pvar i think.
Reply
#4

Can someone say that what is rong at this func??:

pawn Код:
SetPVarString(playerid,"RegDate",savingstring2);
Reply
#5

Nothing is wrong with that line of code. Your not getting the value from the DB. See if there is a debug function for your plugin or something similar.
Reply
#6

He is using G-sTyLeZzZ plugin. The issue is probably that titanak has misspelt the column name in the database.
Reply
#7

but when i add GetPvarString to my format script then it shows empty space .
Reply
#8

Read what iggy1 said in post #2 then post your result.
Reply
#9

no results.

pawn Код:
,GetPVarString(clickedplayerid, "RegDate",regdate,50) // not wrong ?
Reply
#10

This is the last time I'm going to try explain this to you. Put mysql_debug(1); at the top of you script. Go into your server directory and find the mysql debug file. Post the contents of that file here.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)