Query cuts off while executing.
#1

This was in my mysql_log.txt:
pawn Код:
[18:38:01 | Edited 18:38:09] Jamie.: [18:35:15] [DEBUG] mysql_query - connection: 1, query: "INSERT INTO `server_vehicles` (rModel, rColour1, rColour2, isRen", use_cache: true
The "query" is set to 1000(global var).

pawn Код:
CMD:createveh(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5)
    {
        new Float:x, Float:y, Float:z, Float:a, job, faction, rental, model, colour1, colour2;
        new rentalid = RentalGetFreeSlot();
        GetPlayerPos(playerid, x, y, z);
        GetPlayerFacingAngle(playerid, a);
        if(sscanf(params, "dddddd", model, colour1, colour2, rental, faction, job)) return SendClientMessage(playerid, COLOR_RED, "Error:"COL_WHITE" //createveh [model] [colour1] [colour2] [Rental] [Faction] [Job]");
        format(query, sizeof(query), "INSERT INTO `server_vehicles` (rModel, rColour1, rColour2, isRental, isFaction, isJob, rPosX, rPosY, rPosZ, rPosA) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%f', '%f', '%f', '%f')", model, colour1, colour2, rental, faction, job, x, y, z, a);
        mysql_query(sqldb, query);
        RentalInfo[rentalid][rID] = CreateVehicle(RentalInfo[rentalid][rModel], RentalInfo[rentalid][rPosX], RentalInfo[rentalid][rPosY], RentalInfo[rentalid][rPosZ], RentalInfo[rentalid][rPosA], RentalInfo[rentalid][rColour1], RentalInfo[rentalid][rColour2], -1);
        rCreated[rentalid] = true;
    }
    return true;
}
Reply
#2

Don't use a global variable for these kinds of things... I've seen it ruin scripts all too easily.
Reply
#3

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
Don't use a global variable for these kinds of things... I've seen it ruin scripts all too easily.
@BenzoAMG Not really, an array with huge sizes such as big dialog and queries for me global is better, but sometimes people forget to clear the string before using it again.

@[MP]Ditch - make sure you clear the string after or before using it again it's like not freeing a result in mysql and it gets trapped.

pawn Код:
CMD:createveh(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5)
    {
        new Float:x, Float:y, Float:z, Float:a, job, faction, rental, model, colour1, colour2;
        new rentalid = RentalGetFreeSlot();
        GetPlayerPos(playerid, x, y, z);
        GetPlayerFacingAngle(playerid, a);
        if(sscanf(params, "dddddd", model, colour1, colour2, rental, faction, job)) return SendClientMessage(playerid, COLOR_RED, "Error:"COL_WHITE" //createveh [model] [colour1] [colour2] [Rental] [Faction] [Job]");
        query[0] = EOS;
        format(query, sizeof(query), "INSERT INTO `server_vehicles` (rModel, rColour1, rColour2, isRental, isFaction, isJob, rPosX, rPosY, rPosZ, rPosA) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%f', '%f', '%f', '%f')", model, colour1, colour2, rental, faction, job, x, y, z, a);
        mysql_query(sqldb, query);
        RentalInfo[rentalid][rID] = CreateVehicle(RentalInfo[rentalid][rModel], RentalInfo[rentalid][rPosX], RentalInfo[rentalid][rPosY], RentalInfo[rentalid][rPosZ], RentalInfo[rentalid][rPosA], RentalInfo[rentalid][rColour1], RentalInfo[rentalid][rColour2], -1);
        rCreated[rentalid] = true;
    }
    return true;
}
Reply
#4

So when should I use mysql_free_result(); on every query I execute?
Reply
#5

Quote:
Originally Posted by [MP]Ditch
Посмотреть сообщение
So when should I use mysql_free_result(); on every query I execute?
No, I was using it as an example 'storing a result without freeing it.' Are you sure that the query is empty (no other strings stored to it)? nothing is in it? that's why I said to make sure the query array is empty, use EOS or '\0' after or before you used query, try the code I gave you ^..
Reply
#6

Well, it seems to work now. Data is being stored! Thanks anyway!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)