MySQL Syntax Error
#1

Can anyone seem to find what's wrong in this syntax?

Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `accs` SET `pName` = %e, `pSecKey` = %d, `pLevel` = %d, `pRespect` = %d, `pSkin` = %d, `pIP` = %e, `pAdmin` = %d, `pVIP` = %d, `pMoney` = %d, `pGender` = %d, `pAge` = %d, `pBank` = %d, `pBanned` = %d, `pBans` = %d, `pBannedBy` = %e, `pBanReason` = %e, `pBanDate` = %e, `pBanTime` = %e, `pBanAppealable` = %d, `pFaction` = %d, `pRank` = %d, `pFacSkin` = %d, `pTester` = %d, `pTutStep` = %d, `pFinishedTut` = %d, `pMuted` = %d, `pPosX` = %f, `pPosY` = %f, `pPosZ` = %f, `pPosA` = %f WHERE `pID` = %d"
Код:
[05:13:41] [part] Jason_Vienna has left the server (0:1)
[05:13:41] [SQL-ERR][] EID: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 '.255.255, `pAdmin` = 0, `pVIP` = 0, `pMoney` = 0, `pGender` = 0, `pAge` = 0, `pB' at line 1
[05:13:41] UPDATE `accs` SET `pName` = Test_Account, `pSecKey` = 0, `pLevel` = 0, `pRespect` = 0, `pSkin` = 0, `pIP` = 255.255.255.255, `pAdmin` = 0, `pVIP` = 0, `pMoney` = 0, `pGender` = 0, `pAge` = 0, `pBank` = 0, `pBanned` = 0, `pBans` = 0, `pBannedBy` = , `pBanReason` = , `pBanDate` = , `pBanTime` = , `pBanAppealable` = 0, `pFaction` = 0, `pRank` = 0, `pFacSkin` = 0, `pTester` = 0, `pTutStep` = 0, `pFinishedTut` = 0, `pMuted` = 1125808864, `pPosX` = -80.625, `pPosY` = 1.578, `pPosZ` = 132.06, `pPosA` = 7.006e-45 WHERE `pID` =
Reply
#2

Код:
[05:13:41] UPDATE `accs` SET `pName` = Test_Account, `pSecKey` = 0, `pLevel` = 0, `pRespect` = 0, `pSkin` = 0, `pIP` = 255.255.255.255, `pAdmin` = 0, `pVIP` = 0, `pMoney` = 0, `pGender` = 0, `pAge` = 0, `pBank` = 0, `pBanned` = 0, `pBans` = 0, `pBannedBy` = , `pBanReason` = , `pBanDate` = , `pBanTime` = , `pBanAppealable` = 0, `pFaction` = 0, `pRank` = 0, `pFacSkin` = 0, `pTester` = 0, `pTutStep` = 0, `pFinishedTut` = 0, `pMuted` = 1125808864, `pPosX` = -80.625, `pPosY` = 1.578, `pPosZ` = 132.06, `pPosA` = 7.006e-45 WHERE `pID` =
pName and pIP aren't integers, they're strings. You'll need to use quotes.

Also, it doesn't look like you're passing anything for pID?

Is the integer for pID being defined and passed or is it just being cut off? Your string might not be big enough for the query if so.
Reply
#3

You must add quotes around IP - it's a string, not a number
Reply
#4

PHP код:
mysql_format(mysqlquerysizeof(query), "UPDATE `accs` SET `pName` = '%s', `pSecKey` = %d, `pLevel` = %d, `pRespect` = %d, `pSkin` = %d, `pIP` = '%s', `pAdmin` = %d, `pVIP` = %d, `pMoney` = %d, `pGender` = %d, `pAge` = %d, `pBank` = %d, `pBanned` = %d, `pBans` = %d, `pBannedBy` = '%s', `pBanReason` = '%s',  `pBanDate` = '%s', `pBanTime` = '%s', `pBanAppealable` = %d, `pFaction` = %d, `pRank` = %d, `pFacSkin` = %d, `pTester` = %d, `pTutStep` = %d, `pFinishedTut` = %d, `pMuted` = %d, `pPosX` = %f, `pPosY` = %f, `pPosZ` = %f, `pPosA` = %f WHERE `pID` = %d" 
try that



_
as for the post above me..
If you read the error, You clearly see the issue.

The "IP" is being define as %e
an he's attempting to pass it through to a "VARCHAR" column, Hence why it opens the column into '255.255,
Reply
#5

The IP, trying that out, but mister prokill I'm not using %s instead of %e.
Reply
#6

Quote:
Originally Posted by JaydenJason
Посмотреть сообщение
The IP, trying that out, but mister prokill I'm not using %s instead of %e.
You realize, You're passing a STRING.

There for using %e is redundant..

You may as well pass the STRING to the VARCHAR as your table = VARCHAR..


Next time don't ask for help if you don't like the answer given.

I've just created a dummy table an run my syntax , It works..
So, Why are you using %e making a redundant statement.

You should only be using %e
If you're using INNER Joins and or selecting informations across multiple tables.
Reply
#7

Realistically, you don't need to escape IP addresses, but it won't really make a difference.


Quote:
Originally Posted by Prokill911
Посмотреть сообщение
You realize, You're passing a STRING.

There for using %e is redundant..

You may as well pass the STRING to the VARCHAR as your table = VARCHAR..


Next time don't ask for help if you don't like the answer given.

I've just created a dummy table an run my syntax , It works..
So, Why are you using %e making a redundant statement.
Using %e shouldn't make a difference since %e is only escaping the string.
Reply
#8

Quote:
Originally Posted by rymax99
Посмотреть сообщение
Realistically, you don't need to escape IP addresses, but it won't really make a difference.



Using %e shouldn't make a difference since %e is only escaping the string.
Yea, You're ESCAPING the string, So if the string is greater than the given value in his script it sends an empty or w.e many digits the script is allowing.
Whilst if he is sending string, The sizeof is already defined in the script anyway..


It's called clean code..
It's pointless adding redundant checks when you're sending your query..
You should be doing the checks BEFORE the query is sent.
Otherwise you end up with information that could be incorrectly passed
Reply
#9

Quote:
Originally Posted by Prokill911
Посмотреть сообщение
Yea, You're ESCAPING the string, So if the string is greater than the given value in his script it sends an empty or w.e many digits the script is allowing.
Whilst if he is sending string, The sizeof is already defined in the script anyway..
I'm sorry?

https://sampwiki.blast.hk/wiki/MySQL#Format_strings

You're ecaping the pIP string, the pIP string legnth doesn't have anything to do with it.
Reply
#10

Quote:
Originally Posted by rymax99
Посмотреть сообщение
Код:
[05:13:41] UPDATE `accs` SET `pName` = Test_Account, `pSecKey` = 0, `pLevel` = 0, `pRespect` = 0, `pSkin` = 0, `pIP` = 255.255.255.255, `pAdmin` = 0, `pVIP` = 0, `pMoney` = 0, `pGender` = 0, `pAge` = 0, `pBank` = 0, `pBanned` = 0, `pBans` = 0, `pBannedBy` = , `pBanReason` = , `pBanDate` = , `pBanTime` = , `pBanAppealable` = 0, `pFaction` = 0, `pRank` = 0, `pFacSkin` = 0, `pTester` = 0, `pTutStep` = 0, `pFinishedTut` = 0, `pMuted` = 1125808864, `pPosX` = -80.625, `pPosY` = 1.578, `pPosZ` = 132.06, `pPosA` = 7.006e-45 WHERE `pID` =
pName and pIP aren't integers, they're strings. You'll need to use quotes.

Also, it doesn't look like you're passing anything for pID?

Is the integer for pID being defined and passed or is it just being cut off? Your string might not be big enough for the query if so.
pName might not be in integer, but it does save, so I doubt it's anything with pname, also


pIP shows the correct ip to me


Код:
pData[playerid][pID] = cache_get_field_content_int(0, "pID");
Everything is fine with the pID.

My string is big enough..
Tables get updated

Testing with quotes right now, will get back to this in a sec.


Using IP as a integer just makes it "50"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)