PDA

View Full Version : Query cuts off while executing.


BleverCastard
05/06/2014, 05:19 PM
This was in my mysql_log.txt:
[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).

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;
}

Threshold
05/06/2014, 05:37 PM
Don't use a global variable for these kinds of things... I've seen it ruin scripts all too easily.

Patrick
05/06/2014, 05:41 PM
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.


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;
}

BleverCastard
05/06/2014, 06:00 PM
So when should I use mysql_free_result(); on every query I execute?

Patrick
05/06/2014, 06:05 PM
Ditch;3065867']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 ^..

BleverCastard
05/06/2014, 06:08 PM
Well, it seems to work now. Data is being stored! Thanks anyway!