'mysql fetch field row' grabs zero?
#1

I'm rather new to the mysql things.. I've been trying to convert my gate system to mysql, and it has gone very well. Everything works (creating, deleting & saving) except for loading the coordinates, model, speed, password and so on.

pawn Код:
LoadGates(playerid)
    {
        for(new i = 0; i != MAX_GATES; i++)
        {
            if(GateInfo[i][gCreated] == 0)
            {
                new query[300];
                new string[64];
                new savingstring[20];
                format(query, sizeof(query), "SELECT model, x, y, z, xm, ym, zm, rx, ry, rz, speed, password WHERE id = '%d'", i);
                mysql_query(query);
                mysql_store_result();
                while(mysql_fetch_row_format(query, "|"))
                {
                    mysql_fetch_field_row(savingstring, "model"); GateInfo[i][gModel] = strval(savingstring);
                    mysql_fetch_field_row(savingstring, "x"); GateInfo[i][gPosX] = strval(savingstring);
                    mysql_fetch_field_row(savingstring, "y"); GateInfo[i][gPosY] = strval(savingstring);
                    mysql_fetch_field_row(savingstring, "z"); GateInfo[i][gPosZ] = strval(savingstring);
                    mysql_fetch_field_row(savingstring, "xm"); GateInfo[i][gPosXM] = strval(savingstring);
                    mysql_fetch_field_row(savingstring, "ym"); GateInfo[i][gPosYM] = strval(savingstring);
                    mysql_fetch_field_row(savingstring, "zm"); GateInfo[i][gPosZM] = strval(savingstring);
                    mysql_fetch_field_row(savingstring, "rx"); GateInfo[i][gRX] = strval(savingstring);
                    mysql_fetch_field_row(savingstring, "ry"); GateInfo[i][gRY] = strval(savingstring);
                    mysql_fetch_field_row(savingstring, "rz"); GateInfo[i][gRZ] = strval(savingstring);
                    mysql_fetch_field_row(savingstring, "speed"); GateInfo[i][gSpeed] = strval(savingstring);
                    mysql_fetch_field_row(savingstring, "status"); GateInfo[i][gStatus] = strval(savingstring);
                    mysql_fetch_field_row(savingstring, "password"); GateInfo[i][gPassword] = strval(savingstring);
                }
                GateInfo[i][gObject] = CreateObject(988, GateInfo[i][gPosX], GateInfo[i][gPosY], GateInfo[i][gPosZ], 0, 0, 0);
                //GateInfo[i][gObject] = CreateObject(GateInfo[i][gModel], GateInfo[i][gPosX], GateInfo[i][gPosY], GateInfo[i][gPosZ], GateInfo[i][gRX], GateInfo[i][gRY], GateInfo[i][gRZ]);
                GateInfo[i][gNear] = IsPlayerInRangeOfPoint(playerid, 15.0, GateInfo[i][gPosX], GateInfo[i][gPosY], GateInfo[i][gPosZ]);
                format(string, sizeof(string), "988, %f, %f, %f, 0, 0, 0", GateInfo[i][gPosX], GateInfo[i][gPosY], GateInfo[i][gPosZ]);
                print(string);
            }
        }
    }
When I use any of the information I've fetched using mysql_fetch_field row, it outputs zero. Like in the format & print I did to 'debug'. Everything comes out zero (except for the 988 ofcourse.)
Reply
#2

Well one thing is it looks that in your query you select everything, so you should use SELET *,which means select everything.

I can't see other problems.
Reply
#3

So "SELECT * WHERE id='%d'" ?

EDIT: Oh my god.. I feel dumb.. I forgot to specify the table name "SELECT * FROM gates WHERE id='%d'"
Reply
#4

Yes "SELET * FROM gates WHERE id='%d'",even better,you arrived at the problem yourself!
Reply
#5

Yea, I've been trying to figure it out all night though. :P
Reply
#6

strval is for integers ONLY! For floats you need floatstr and for strings you don't need anything.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)