PDA

View Full Version : Any wrong in this code?


TheCartman
23/01/2015, 10:56 PM
Hi guys. I didn't see any wrong thing here:

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:
[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!

Zume
23/01/2015, 11:09 PM
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

Vince
23/01/2015, 11:25 PM
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.

http://puu.sh/eW3zX/69db0dc743.png

TheCartman
24/01/2015, 05:58 AM
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.

http://puu.sh/eW3zX/69db0dc743.png

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...

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...

TheCartman
24/01/2015, 02:14 PM
Can someone help me? I see nothing wrong here...