A few MySQL errors
#1

Код:
D:\MySQL\gamemodes\ALRP.pwn(3196) : error 075: input line too long (after substitutions)
D:\MySQL\gamemodes\ALRP.pwn(3197) : error 037: invalid string (possibly non-terminated string)
D:\MySQL\gamemodes\ALRP.pwn(3197) : error 017: undefined symbol "UPDATE"
D:\MySQL\gamemodes\ALRP.pwn(3197) : error 029: invalid expression, assumed zero
D:\MySQL\gamemodes\ALRP.pwn(3197) : fatal error 107: too many error messages on one line
Lines
Код:
			mysql_format(mysql, query, sizeof(query), "UPDATE `users` SET `IP`='%s', `Gender`='%d', `Level`='%d', `UpgradePoints`='%d', `ArmorUpgrade`='%d', `Minutes`='%d', `TMinutes`='%d', `Hours`='%d', `Age`='%d', `Cash`='%d', `Bank`='%d',\
			`Model`='%d', `Admin`='%d', `OldAdmin`='%d', `Mapper`='%d', `pBanned`='%d', `Phnumber`='%d', `AdMute`='%d', `JackSkill`='%d', `Death`='%d', `Dead`='%d', `Died`='%d', `Kill`='%d', `X`='%f', `Y`='%f', `Z`='%f',\
		 	`Int`='%d', `VW`='%d', `VehVW`='%d', `WalkStyle`='%d', `Neon`='%d', `vNeon`='%d', `Fac`='%d', `FacRank`='%d', `FacLeader`='%d', `FacDiv`='%d', `FacDivLeader`='%d', `Duty`='%d', `wSlot0`='%d', `wSlot0Ammo`='%d' \
		 	WHERE `ID`='%d'", PlayerInfo[playerid][pIP], PlayerInfo[playerid][pGender], PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pUpgradePoints], PlayerInfo[playerid][pArmorUpgrade], PlayerInfo[playerid][pMinutes], PlayerInfo[playerid][pTMinutes],\
		 	PlayerInfo[playerid][pHours], PlayerInfo[playerid][pExp], PlayerInfo[playerid][pAge], PlayerInfo[playerid][pMoney], PlayerInfo[playerid][pBank], PlayerInfo[playerid][pModel], PlayerInfo[playerid][pAdmin],\
		 	PlayerInfo[playerid][pOldAdmin], PlayerInfo[playerid][pMapper], PlayerInfo[playerid][pBanned], PlayerInfo[playerid][pNumber], PlayerInfo[playerid][pADMute], PlayerInfo[playerid][pJackSkill],\
		 	PlayerInfo[playerid][pDeath], PlayerInfo[playerid][pDead], PlayerInfo[playerid][pDied], PlayerInfo[playerid][pKill], PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ],\
		 	PlayerInfo[playerid][pZ], PlayerInfo[playerid][pInt], PlayerInfo[playerid][pVW], PlayerInfo[playerid][pVehVW], PlayerInfo[playerid][pWalkStyle], PlayerInfo[playerid][pNeon], PlayerInfo[playerid][pVNeon]\
		 	PlayerInfo[playerid][pFac], PlayerInfo[playerid][pFacRank], PlayerInfo[playerid][pFacLeader], PlayerInfo[playerid][pFacLeader], PlayerInfo[playerid][pFacDiv], PlayerInfo[playerid][pFacDivLeader],\
		 	PlayerInfo[playerid][pFacDuty], PlayerInfo[playerid][pWeapon][0], PlayerInfo[playerid][pWeaponAmmo][0], PlayerInfo[playerid][pID]);
			mysql_tquery(mysql, query);
Red lines are 96 + 97
Thanks in advice
Reply
#2

The line is too long. You can use format along with strcat or write a stored procedure.
Reply
#3

If you are planning to use MySQL, learn it first.
This topic will help you learn how to normalize them.
https://sampforum.blast.hk/showthread.php?tid=420363
here are tips, vehicle and weapons are not part of the player itself, but related to it, hence they should be in a different table. Same goes for faction and a lot others.
Reply
#4

Gamer, either help or quit. This section is just to help them. Don't try to be a smart-ass.

OT:
You don't need to use "\" while giving the values for the variables. You just use it while using format on a large item. Give it a try.
pawn Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `users` SET `IP`='%s', `Gender`='%d', `Level`='%d', `UpgradePoints`='%d', `ArmorUpgrade`='%d', `Minutes`='%d', `TMinutes`='%d', `Hours`='%d', `Age`='%d', `Cash`='%d', `Bank`='%d',\
            `Model`='%d', `Admin`='%d', `OldAdmin`='%d', `Mapper`='%d', `pBanned`='%d', `Phnumber`='%d', `AdMute`='%d', `JackSkill`='%d', `Death`='%d', `Dead`='%d', `Died`='%d', `Kill`='%d', `X`='%f', `Y`='%f', `Z`='%f',\
            `Int`='%d', `VW`='%d', `VehVW`='%d', `WalkStyle`='%d', `Neon`='%d', `vNeon`='%d', `Fac`='%d', `FacRank`='%d', `FacLeader`='%d', `FacDiv`='%d', `FacDivLeader`='%d', `Duty`='%d', `wSlot0`='%d', `wSlot0Ammo`='%d' \
            WHERE `ID`='%d'"
, PlayerInfo[playerid][pIP], PlayerInfo[playerid][pGender], PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pUpgradePoints], PlayerInfo[playerid][pArmorUpgrade], PlayerInfo[playerid][pMinutes], PlayerInfo[playerid][pTMinutes],
            PlayerInfo[playerid][pHours], PlayerInfo[playerid][pExp], PlayerInfo[playerid][pAge], PlayerInfo[playerid][pMoney], PlayerInfo[playerid][pBank], PlayerInfo[playerid][pModel], PlayerInfo[playerid][pAdmin],
            PlayerInfo[playerid][pOldAdmin], PlayerInfo[playerid][pMapper], PlayerInfo[playerid][pBanned], PlayerInfo[playerid][pNumber], PlayerInfo[playerid][pADMute], PlayerInfo[playerid][pJackSkill],
            PlayerInfo[playerid][pDeath], PlayerInfo[playerid][pDead], PlayerInfo[playerid][pDied], PlayerInfo[playerid][pKill], PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ],
            PlayerInfo[playerid][pZ], PlayerInfo[playerid][pInt], PlayerInfo[playerid][pVW], PlayerInfo[playerid][pVehVW], PlayerInfo[playerid][pWalkStyle], PlayerInfo[playerid][pNeon], PlayerInfo[playerid][pVNeon]
            PlayerInfo[playerid][pFac], PlayerInfo[playerid][pFacRank], PlayerInfo[playerid][pFacLeader], PlayerInfo[playerid][pFacLeader], PlayerInfo[playerid][pFacDiv], PlayerInfo[playerid][pFacDivLeader],
            PlayerInfo[playerid][pFacDuty], PlayerInfo[playerid][pWeapon][0], PlayerInfo[playerid][pWeaponAmmo][0], PlayerInfo[playerid][pID]);
            mysql_tquery(mysql, query);
Reply
#5

At least he attempts to solve the problem properly instead of supplying a cheap workaround that won't hold as more columns get added to this already enormous table.
Reply
#6

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
If you are planning to use MySQL, learn it first.
This topic will help you learn how to normalize them.
https://sampforum.blast.hk/showthread.php?tid=420363
here are tips, vehicle and weapons are not part of the player itself, but related to it, hence they should be in a different table. Same goes for faction and a lot others.
Well yeah it would make it way better
I have created the weapons table for example but I didn't really understand how to link it with the "parent" table "users"
Reply
#7

Quote:
Originally Posted by Vince
Посмотреть сообщение
At least he attempts to solve the problem properly instead of supplying a cheap workaround that won't hold as more columns get added to this already enormous table.
(sorry for double posting)

Same error lines:
PHP код:
            mysql_format(mysqlquerysizeof(query), "UPDATE `weapons` SET `wSlot0`='%d', `wSlot0Ammo`='%d', `wSlot1`='%d', `wSlot1Ammo`='%d', `wSlot2`='%d', `wSlot2Ammo`='%d', `wSlot3`='%d',\
             `wSlot3Ammo`='%d', `wSlot4`='%d', `wSlot4Ammo`='%d', `wSlot5`='%d', `wSlot5Ammo`='%d', `wSlot6`='%d', `wSlot6Ammo`='%d', `wSlot7`='%d', `wSlot7Ammo`='%d',\
            `wSlot8`='%d', `wSlot8Ammo`='%d', `wSlot9`='%d', `wSlot9Ammo`='%d', `wSlot10`='%d', `wSlot10Ammo`='%d', `wSlot11`='%d', `wSlot11Ammo`='%d', `wSlot12`='%d', `wSlot12Ammo`='%d' WHERE `ID`='%d'"
,
            
PlayerInfo[playerid][pWeapon][0], PlayerInfo[playerid][pWeaponAmmo][0],
            
PlayerInfo[playerid][pWeapon][1], PlayerInfo[playerid][pWeaponAmmo][1],
            
PlayerInfo[playerid][pWeapon][2], PlayerInfo[playerid][pWeaponAmmo][2],
            
PlayerInfo[playerid][pWeapon][3], PlayerInfo[playerid][pWeaponAmmo][3],
            
PlayerInfo[playerid][pWeapon][4], PlayerInfo[playerid][pWeaponAmmo][4],
            
PlayerInfo[playerid][pWeapon][5], PlayerInfo[playerid][pWeaponAmmo][5],
            
PlayerInfo[playerid][pWeapon][6], PlayerInfo[playerid][pWeaponAmmo][6],
            
PlayerInfo[playerid][pWeapon][7], PlayerInfo[playerid][pWeaponAmmo][7],
            
PlayerInfo[playerid][pWeapon][8], PlayerInfo[playerid][pWeaponAmmo][8],
            
PlayerInfo[playerid][pWeapon][9], PlayerInfo[playerid][pWeaponAmmo][9],
            
PlayerInfo[playerid][pWeapon][10], PlayerInfo[playerid][pWeaponAmmo][10],
            
PlayerInfo[playerid][pWeapon][11], PlayerInfo[playerid][pWeaponAmmo][11],
            
PlayerInfo[playerid][pWeapon][12], PlayerInfo[playerid][pWeaponAmmo][12],
            
PlayerInfo[playerid][pID]); 
Why does it mark UPDATE as unknown symbol ?
Reply
#8

Quote:

'%d' \

You forgot a comma, it seems.
Reply
#9

Quote:
Originally Posted by biker122
Посмотреть сообщение
Gamer, either help or quit. This section is just to help them. Don't try to be a smart-ass.

OT:
You don't need to use "\" while giving the values for the variables. You just use it while using format on a large item. Give it a try.
Sorry I'm not a rep hunter like you and I actually try to get people to learn why something has happened and how to fix it, which in this case is not because of mysql_format, but because of the wrong table setup.

Quote:
Originally Posted by NeXoR
Посмотреть сообщение
(sorry for double posting)

Same error lines:
PHP код:
            mysql_format(mysqlquerysizeof(query), "UPDATE `weapons` SET `wSlot0`='%d', `wSlot0Ammo`='%d', `wSlot1`='%d', `wSlot1Ammo`='%d', `wSlot2`='%d', `wSlot2Ammo`='%d', `wSlot3`='%d',\
             `wSlot3Ammo`='%d', `wSlot4`='%d', `wSlot4Ammo`='%d', `wSlot5`='%d', `wSlot5Ammo`='%d', `wSlot6`='%d', `wSlot6Ammo`='%d', `wSlot7`='%d', `wSlot7Ammo`='%d',\
            `wSlot8`='%d', `wSlot8Ammo`='%d', `wSlot9`='%d', `wSlot9Ammo`='%d', `wSlot10`='%d', `wSlot10Ammo`='%d', `wSlot11`='%d', `wSlot11Ammo`='%d', `wSlot12`='%d', `wSlot12Ammo`='%d' WHERE `ID`='%d'"
,
            
PlayerInfo[playerid][pWeapon][0], PlayerInfo[playerid][pWeaponAmmo][0],
            
PlayerInfo[playerid][pWeapon][1], PlayerInfo[playerid][pWeaponAmmo][1],
            
PlayerInfo[playerid][pWeapon][2], PlayerInfo[playerid][pWeaponAmmo][2],
            
PlayerInfo[playerid][pWeapon][3], PlayerInfo[playerid][pWeaponAmmo][3],
            
PlayerInfo[playerid][pWeapon][4], PlayerInfo[playerid][pWeaponAmmo][4],
            
PlayerInfo[playerid][pWeapon][5], PlayerInfo[playerid][pWeaponAmmo][5],
            
PlayerInfo[playerid][pWeapon][6], PlayerInfo[playerid][pWeaponAmmo][6],
            
PlayerInfo[playerid][pWeapon][7], PlayerInfo[playerid][pWeaponAmmo][7],
            
PlayerInfo[playerid][pWeapon][8], PlayerInfo[playerid][pWeaponAmmo][8],
            
PlayerInfo[playerid][pWeapon][9], PlayerInfo[playerid][pWeaponAmmo][9],
            
PlayerInfo[playerid][pWeapon][10], PlayerInfo[playerid][pWeaponAmmo][10],
            
PlayerInfo[playerid][pWeapon][11], PlayerInfo[playerid][pWeaponAmmo][11],
            
PlayerInfo[playerid][pWeapon][12], PlayerInfo[playerid][pWeaponAmmo][12],
            
PlayerInfo[playerid][pID]); 
Why does it mark UPDATE as unknown symbol ?
Can't seem to find a problem in the code you posted tho, will check it carefully later and edit the post.

But this looks like you actually want to learn and not just fix a problem, so here are some tips

A) when sending queries to SQL, only put the value between ' ' when sending a string, integers floats and bools don't need it
B) for making a link between 2 tables, they should have something in common, I.E a id, names can differ but you can't make a connection between a for example a 12 character long string and a 50 character long one, same goes for integer sizes.
C) You are doing the normalization wrong tho, here is how your query should look like
PHP код:
UPDATE `weaponsSET `weapon`=%d, `ammo`=%d WHERE `id`=%AND `slot`=%
that structure makes your rows count into 4, and allows you to do so many things, for example if you ever need a weaponslot 15 (which probably won't happen for weapons, but might happen for lets say vehicles) you need to alter your table, but with the structure I suggested you simply put slot id 15 and insert/update
in my case id and slot are both unique, so you can also use REPLACE keyword, which essentially updates if exists, inserts if not

I might miss your answer so PM me if needed
Reply
#10

Quote:
Originally Posted by NeXoR
Посмотреть сообщение
(sorry for double posting)

Same error lines:
PHP код:
            mysql_format(mysqlquerysizeof(query), "UPDATE `weapons` SET `wSlot0`='%d', `wSlot0Ammo`='%d', `wSlot1`='%d', `wSlot1Ammo`='%d', `wSlot2`='%d', `wSlot2Ammo`='%d', `wSlot3`='%d',\
             `wSlot3Ammo`='%d', `wSlot4`='%d', `wSlot4Ammo`='%d', `wSlot5`='%d', `wSlot5Ammo`='%d', `wSlot6`='%d', `wSlot6Ammo`='%d', `wSlot7`='%d', `wSlot7Ammo`='%d',\
            `wSlot8`='%d', `wSlot8Ammo`='%d', `wSlot9`='%d', `wSlot9Ammo`='%d', `wSlot10`='%d', `wSlot10Ammo`='%d', `wSlot11`='%d', `wSlot11Ammo`='%d', `wSlot12`='%d', `wSlot12Ammo`='%d' WHERE `ID`='%d'"
,
            
PlayerInfo[playerid][pWeapon][0], PlayerInfo[playerid][pWeaponAmmo][0],
            
PlayerInfo[playerid][pWeapon][1], PlayerInfo[playerid][pWeaponAmmo][1],
            
PlayerInfo[playerid][pWeapon][2], PlayerInfo[playerid][pWeaponAmmo][2],
            
PlayerInfo[playerid][pWeapon][3], PlayerInfo[playerid][pWeaponAmmo][3],
            
PlayerInfo[playerid][pWeapon][4], PlayerInfo[playerid][pWeaponAmmo][4],
            
PlayerInfo[playerid][pWeapon][5], PlayerInfo[playerid][pWeaponAmmo][5],
            
PlayerInfo[playerid][pWeapon][6], PlayerInfo[playerid][pWeaponAmmo][6],
            
PlayerInfo[playerid][pWeapon][7], PlayerInfo[playerid][pWeaponAmmo][7],
            
PlayerInfo[playerid][pWeapon][8], PlayerInfo[playerid][pWeaponAmmo][8],
            
PlayerInfo[playerid][pWeapon][9], PlayerInfo[playerid][pWeaponAmmo][9],
            
PlayerInfo[playerid][pWeapon][10], PlayerInfo[playerid][pWeaponAmmo][10],
            
PlayerInfo[playerid][pWeapon][11], PlayerInfo[playerid][pWeaponAmmo][11],
            
PlayerInfo[playerid][pWeapon][12], PlayerInfo[playerid][pWeaponAmmo][12],
            
PlayerInfo[playerid][pID]); 
Why does it mark UPDATE as unknown symbol ?
Because the line is too long so 'UPDATE' being interpreted as a symbol and not part of a string (guess). I'll try explain, the code you posted is just one line of code. And it is too long. It may be spread over many lines in the text editor, but it is a single line of code. (just 1 statement)

You have 2 options:
1) Break that line up into many lines. (not recommended, i feel bad for mentioning it)
B) As others have said, normalize your database and then you would not need to use a query that insanely long. (Highly recommended)

So the error is actually caused because that line of CODE (not string) is too long, that includes the function header, string and variables. And is not a MYSQL error.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)