PDA

View Full Version : Query problem


TwinkiDaBoss
04/12/2015, 09:28 PM
Okay so the problem is simple as it can be. The query will always insert FactionID as 0.

I printed the result
[pawn][23:22:43] INSERT INTO `vehicles` (`MasterID`,`ModelID`,`Color1`,`Color2`,`PosX`,`Po sY`,`PosZ`,`PosA`,`RespawnTime`,`Price`,`Damage`,` FuelStatus`,`EngineStatus`,`Kilometrage`,`Siren`,` Owned`,`VirtualWorld`,`Interior`,`FactionID`) VALUES ('0','411','0','0','1585.514','-1625.23','13.383','273.748','0','220000','1000','0 ','0','0.0',0,1,0,0,'0')[/php]

Code used
mysql_format(mysql, query, sizeof(query),"INSERT INTO `vehicles` (`MasterID`,`ModelID`,`Color1`,`Color2`,`PosX`,`Po sY`,`PosZ`,`PosA`,`RespawnTime`,`Price`,`Damage`,` FuelStatus`,`EngineStatus`,`Kilometrage`,`Siren`,` Owned`,`VirtualWorld`,`Interior`,`FactionID`,`Lock ed`) VALUES ('%i','%i','%i','%i','%f','%f','%f','%f','%i','%i' ,'%i','%i','%i','%f',0,1,0,0,'%i',0)",\
0,vid,0,0,Pos[0],Pos[1],Pos[2],Pos[3],0,GetVehiclePrice(vid),1000,0,0,0,0,0,0,0,AccInfo[playerid][PlayerFaction],0);
mysql_tquery(mysql, query, "OnVehicleCreation", "i", playerid);


Everything gets inserted correctly besides AccInfo[playerid][PlayerFaction], which always stores as 0. I printed out the AccInfo[playerid][PlayerFaction] and it gave me correct result



printf("%i faction ID || 2nd %i ",VehInfo[vehicleid][VehFaction],AccInfo[playerid][PlayerFaction]);
[23:22:43] 1 faction ID || 2nd 1


No errors inside the SQL log

Abagail
04/12/2015, 09:36 PM
Print the query. Also, integer values shouldn't be treated as strings. As such you don't need to wrap them in single quotes.

TwinkiDaBoss
04/12/2015, 09:49 PM
[23:22:43] INSERT INTO `vehicles` (`MasterID`,`ModelID`,`Color1`,`Color2`,`PosX`,`Po sY`,`PosZ`,`PosA`,`RespawnTime`,`Price`,`Damage`,` FuelStatus`,`EngineStatus`,`Kilometrage`,`Siren`,` Owned`,`VirtualWorld`,`Interior`,`FactionID`) VALUES ('0','411','0','0','1585.514','-1625.23','13.383','273.748','0','220000','1000','0 ','0','0.0',0,1,0,0,'0')

This was before I added last parameter to it (locked) so dont mind missing 1 var in it

Vince
04/12/2015, 10:08 PM
What is "MasterID"? Is this set to auto increment? As far as I know when any of 0, NULL or DEFAULT are used the auto increment value is used. But since you're listing columns anyway that column can just be omitted from the list.

TwinkiDaBoss
04/12/2015, 10:17 PM
What is "MasterID"? Is this set to auto increment? As far as I know when any of 0, NULL or DEFAULT are used the auto increment value is used. But since you're listing columns anyway that column can just be omitted from the list.

Master ID represents player Account ID (instead of using name) but in this case, Im using this for faction vehicles therefore im leave the master ID to be 0.

SQL ID is
VehInfo[vid][VID] = cache_insert_id();
Used OnVehicleCreation