Any wrong in this code?
#1

Hi guys. I didn't see any wrong thing here:

Code:
format (szQuery, sizeof(szQuery), "%s, `PlayerVehicleModel1`='%d', `PlayerVehicleFacing1`='%f', `PlayerVehicle1Color`='%d', `PlayerVehicle1Color2`='%d', `PlayerVehiclePosX1`='%f'", szQuery, PlayerInfo[playerid][PlayerVehicleModel1],PlayerInfo[playerid][PlayerVehicleFacing1],PlayerInfo[playerid][pPlayerVehicle1Color],PlayerInfo[playerid][pPlayerVehicle1Color2],PlayerInfo[playerid][PlayerVehiclePosX1]);
	
	format (szQuery, sizeof(szQuery), "%s, `PlayerVehiclePosY1`='%f', `PlayerVehiclePosZ1`='%f', `PlayerVehicle1PaintJob`='%d', `PlayerVehicle1Nos`='%d', `PlayerVehicle1ModSlot0`='%d', `PlayerVehicle1ModSlot1`='%d'", szQuery,PlayerInfo[playerid][PlayerVehiclePosY1],PlayerInfo[playerid][PlayerVehiclePosZ1],PlayerInfo[playerid][PlayerVehicle1PaintJob],PlayerInfo[playerid][PlayerVehicle1Nos],PlayerInfo[playerid][PlayerVehicle1ModSlot0],PlayerInfo[playerid][PlayerVehicle1ModSlot1]);
	
	format (szQuery, sizeof(szQuery), "%s, `PlayerVehicle1ModSlot2`='%d', `PlayerVehicle1ModSlot3`='%d', `PlayerVehicle1ModSlot4`='%d', `PlayerVehicle1ModSlot5`='%d', `PlayerVehicle1ModSlot6`='%d'", szQuery,PlayerInfo[playerid][PlayerVehicle1ModSlot2],PlayerInfo[playerid][PlayerVehicle1ModSlot3],PlayerInfo[playerid][PlayerVehicle1ModSlot4],PlayerInfo[playerid][PlayerVehicle1ModSlot5],PlayerInfo[playerid][PlayerVehicle1ModSlot6]);
	
	format (szQuery, sizeof(szQuery), "%s, `PlayerVehicle1ModSlot7`='%d', `PlayerVehicle1ModSlot8`='%d', `PlayerVehicle1ModSlot9`='%d', `PlayerVehicle1ModSlot10`='%d', `PlayerVehicle1ModSlot11`='%d'", szQuery,PlayerInfo[playerid][PlayerVehicle1ModSlot7],PlayerInfo[playerid][PlayerVehicle1ModSlot8],PlayerInfo[playerid][PlayerVehicle1ModSlot9],PlayerInfo[playerid][PlayerVehicle1ModSlot10],PlayerInfo[playerid][PlayerVehicle1ModSlot11]);
	
	format (szQuery, sizeof(szQuery), "%s, `PlayerVehicle1ModSlot12`='%d', `PlayerVehicle1ModSlot13`='%d', `VehLock1`='%d', `VehLocked1`='%d', `PlayerVehicle1Interior`='%d', `PlayerVehicle1VirWorld`='%d'", szQuery,PlayerInfo[playerid][PlayerVehicle1ModSlot12],PlayerInfo[playerid][PlayerVehicle1ModSlot13],PlayerInfo[playerid][pVehLock1],PlayerInfo[playerid][pVehLocked1],PlayerInfo[playerid][PlayerVehicle1Interior],PlayerInfo[playerid][PlayerVehicle1VirWorld]);
But my mysql_log say this:
Code:
[01:28:21] [ERROR] CMySQLQuery::Execute[OnQueryFinish] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`Pla' at line 1
And those lines are the singles who have "`Pla"... I didn't see anything wrong. Did you see? Thanks!
Reply
#2

The first line of the query is not necessary to add the %s, nor szQuery in the grounds of format, in another instance chain may have a lower limit to which was defined
Reply
#3

Why is evident that something like houses or objects gets their own separate tables, yet everything related to the player is crammed into one table? If you need to add a number to a column name then you're doing it wrong. MySQL is an RDBMS. Relational Database Management System. With the emphasis on that first word.

Each player can have zero or more vehicles. That's the first one-to-many relation. Each vehicle can have zero or mods. That's the second one-to-many relation.

Reply
#4

Quote:
Originally Posted by Vince
View Post
Why is evident that something like houses or objects gets their own separate tables, yet everything related to the player is crammed into one table? If you need to add a number to a column name then you're doing it wrong. MySQL is an RDBMS. Relational Database Management System. With the emphasis on that first word.

Each player can have zero or more vehicles. That's the first one-to-many relation. Each vehicle can have zero or mods. That's the second one-to-many relation.

I know this. This is how I get the code, but it was on SQLite. I will change it. But now I need to see what's wrong here...

Quote:
Originally Posted by _Zume
View Post
The first line of the query is not necessary to add the %s, nor szQuery in the grounds of format, in another instance chain may have a lower limit to which was defined
This is just a part of the query... I have ~20 lines with query format, but I think just those are problematics...
Reply
#5

Can someone help me? I see nothing wrong here...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)