MYSQL Query little problem?
#1

Hello everyone i trying to save a vehicle with a query but i dont know why it say this error

PHP Code:
C:\Samp-Server\gamemodes\Rol.pwn(878) : error 075input line too long (after substitutions)
C:\Samp-Server\gamemodes\Rol.pwn(879) : error 037invalid string (possibly non-terminated string)
C:\Samp-Server\gamemodes\Rol.pwn(879) : error 017undefined symbol "UPDATE"
C:\Samp-Server\gamemodes\Rol.pwn(879) : error 029invalid expressionassumed zero
C
:\Samp-Server\gamemodes\Rol.pwn(879) : fatal error 107too many error messages on one line 
Here is my function

PHP Code:
forward SavePlayerVehicles(playerid);
public 
SavePlayerVehicles(playerid)
{
  
//Saving the player vehicles
    
new vehicles_query[800];
     
mysql_format(mysqlHandlevehicles_querysizeof(vehicles_query), "UPDATE `players` SET `CarOneSlot`=%d, `CarOneLock`=%d, `CarOneModel`=%d, `CarOneVirtualWorld`=%d, `CarOneMod1`=%d, `CarOneMod2`=%d, `CarOneMod3`=%d, `CarOneMod4`=%d, `CarOneMod5`=%d, `CarOneMod6`=%d, `CarOneMod7`=%d,`CarOneMod8`=%d, `CarOneMod9`=%d, `CarOneMod10`=%d,\
    `CarOneMod11`=%d, `CarOneMod12`=%d, `CarOneMod13`=%d, `CarOneColor1`=%d, `CarOneColor2`=%d, `CarOneWeapon1`=%d, `CarOneWeapon2`=%d, `CarOneWeapon3`=%d, `CarOneWeapon4`=%d, `CarOneWeapon5`=%d, `CarOneLicensePlate`=%d, `CarOneFuel`=%f, `CarOnePosX`=%f, `CarOnePosY`=%f, `CarOnePosZ`=%f, `CarOnePosA`=%f, `CarOneHealth`=%f WHERE `ID`=%d"
,
    
pInfo[playerid][CarOneSlot],
    
pInfo[playerid][CarOneLock],
    
pInfo[playerid][CarOneModel],
    
pInfo[playerid][CarOneVirtualWorld],
    
pInfo[playerid][CarOneMod][0],
    
pInfo[playerid][CarOneMod][1],
    
pInfo[playerid][CarOneMod][2],
    
pInfo[playerid][CarOneMod][3],
    
pInfo[playerid][CarOneMod][4],
    
pInfo[playerid][CarOneMod][5],
    
pInfo[playerid][CarOneMod][6],
    
pInfo[playerid][CarOneMod][7],
    
pInfo[playerid][CarOneMod][8],
    
pInfo[playerid][CarOneMod][9],
    
pInfo[playerid][CarOneMod][10],
    
pInfo[playerid][CarOneMod][11],
    
pInfo[playerid][CarOneMod][12],
    
pInfo[playerid][CarOneColor][0],
    
pInfo[playerid][CarOneColor][1],
    
pInfo[playerid][CarOneWeapon][0],
    
pInfo[playerid][CarOneWeapon][1],
    
pInfo[playerid][CarOneWeapon][2],
    
pInfo[playerid][CarOneWeapon][3],
    
pInfo[playerid][CarOneWeapon][4],
    
pInfo[playerid][CarOneLicensePlate],
    
pInfo[playerid][CarOneFuel],
    
pInfo[playerid][CarOnePos][0],
    
pInfo[playerid][CarOnePos][1],
    
pInfo[playerid][CarOnePos][2],
    
pInfo[playerid][CarOnePos][3],
    
pInfo[playerid][CarOneHealth],
    
pInfo[playerid][ID]);
    
    
mysql_tquery(mysqlHandlevehicles_query"""");

Any suggestions? thanks in advance
Reply
#2

Use this: https://sampforum.blast.hk/showthread.php?tid=473595

https://github.com/Zeex/pawn

EDIT: https://github.com/Zeex/pawn/release...aries-20140427
Reply
#3

IThanks Mionee, i use it but that compiler isn't compatible with sscanf2 =(
Reply
#4

This is how I do it:
pawn Code:
mysql_format(mysql, query, sizeof(query), "INSERT INTO `playerdata` (Name, Pass, IP, Admin, VIP, Sex, Age, Medic, Mechanic, Athelete, Pilot, SkillSelected, TestPassed, Level, Chips, XP, Zombie, Banned, Society, AMF, Umbrella, PermZombie) VALUES ('%e', '%e', '%e', '0', '0', '%d', '%d', '%d', '%d', '%d', '%d', '1', '1', '1', '50', '1', '0', '0', '1', '0', '0', '0')",
        PlayerInfo[playerid][name], PlayerInfo[playerid][pass], IP1,
        PlayerInfo[playerid][pSex], PlayerInfo[playerid][pAge], PlayerInfo[playerid][pMedic],
        PlayerInfo[playerid][pAthelete], PlayerInfo[playerid][pMechanic], PlayerInfo[playerid][pPilot]);
Reply
#5

Oh god. Don't use one single table for everything. Please. CarMods are not related to players, they're related to cars. That means they need another table. Basically, if you need to add a number to a column name, you're doing it wrong. The "CarOne" also implies there is a "CarTwo", in which case that is wrong, too. Make more rows, less columns. Then you wouldn't have to write ridiculously long and amateuristic queries.

You have ONE player who can own MANY cars. This means you have a table players and a table cars which are linked by a one-to-many relation. Additionally ONE car can have MANY mods which, again, means you have the aforementioned table cars and an additional table carmods which are, once again, linked by a one-to-many relation.

The way I envision it is this:



I don't expect you to understand anything that I just wrote, but I hope at least some of it sinks in.
Reply
#6

Quote:
Originally Posted by Vince
View Post
Oh god. Don't use one single table for everything. Please. CarMods are not related to players, they're related to cars. That means they need another table. Basically, if you need to add a number to a column name, you're doing it wrong. The "CarOne" also implies there is a "CarTwo", in which case that is wrong, too. Make more rows, less columns. Then you wouldn't have to write ridiculously long and amateuristic queries.

You have ONE player who can own MANY cars. This means you have a table players and a table cars which are linked by a one-to-many relation. Additionally ONE car can have MANY mods which, again, means you have the aforementioned table cars and an additional table carmods which are, once again, linked by a one-to-many relation.

The way I envision it is this:



I don't expect you to understand anything that I just wrote, but I hope at least some of it sinks in.
Vince i understand you point and yes is bad idea store these info in players, thanks for you hint i will implement soon on my script, have nice day.

@Topic
I fix the problem using publics (temporally xD)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)