Mysql_format
#1

How much values can i use in this Mysql format ?
and will the same work for strings ?
pawn Код:
mysql_format(g_SQL, query, sizeof(query), "UPDATE `players` SET `money` = '%d' , `score` = '%d' , `string` = '%s' WHERE `id` = '%d' LIMIT 1", Player[playerid][Money],score,string Player[playerid][ID]);
        mysql_tquery(g_SQL, query);
How much variables/strings can i save with once mysql_format ? and can i use both together or is there another way for strings ? what should i set the string size in this i had.
pawn Код:
new query[124]
Reply
#2

mysql_format is such as format function
https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_format
Reply
#3

i have seen this already but i am asking how long can i take it ? and i should be using functions again and again ?
Reply
#4

I can't understand. Please explain
Reply
#5

remove.
Reply
#6

pawn Код:
mysql_format(g_SQL, query, sizeof(query), "UPDATE `players` SET `admin` = '%d' , `owner` = '%d' , `scripter` = '%d' , `donator` = '%d' , `regularplayer` = '%d' , `dj` = '%d' WHERE `id` = '%d' LIMIT 1", PlayerInfo[playerid][pAdmin],PlayerInfo[playerid][pOwner],PlayerInfo[playerid][pScripter],PlayerInfo[playerid][pDonator],PlayerInfo[playerid][pRegularPlayer],PlayerInfo[playerid][pDj],PlayerInfo[playerid][pID]);
        mysql_tquery(g_SQL, query);//3621
This code here gives me error
pawn Код:
(3261) : error 075: input line too long (after substitutions)
but i don't think it's that long.... and in this these all are bools. Any if i should divide it how much more smaller ?

and if i try this
pawn Код:
mysql_format(g_SQL, query, sizeof(query), "UPDATE `players` SET `admin` = '%d' , `owner` = '%d' , `scripter` = '%d' , `donator` = '%d' //3260
        , `regularplayer` = '%d' , `dj` = '%d' WHERE `id` = '%d' LIMIT 1"
, PlayerInfo[playerid][pAdmin],PlayerInfo[playerid][pOwner],//3261
        PlayerInfo[playerid][pScripter],PlayerInfo[playerid][pDonator],PlayerInfo[playerid][pRegularPlayer],PlayerInfo[playerid][pDj],//3262
        PlayerInfo[playerid][pID]);//3263
        mysql_tquery(g_SQL, query);//3264
i get
pawn Код:
(3260) : error 037: invalid string (possibly non-terminated string)
(3260) : error 017: undefined symbol "UPDATE"
(3260) : error 029: invalid expression, assumed zero
(3260) : fatal error 107: too many error messages on one line
Reply
#7

Why so much spacing and ` or ' around every single one? Query's length can be reduced and splitting the arguments will get rid of the error:
pawn Код:
mysql_format(g_SQL, query, sizeof(query), "UPDATE players SET admin=%d,owner=%d,scripter=%d,donator=%d,regularplayer=%d,dj=%d WHERE id=%d LIMIT 1",
PlayerInfo[playerid][pAdmin],PlayerInfo[playerid][pOwner],PlayerInfo[playerid][pScripter],PlayerInfo[playerid][pDonator],PlayerInfo[playerid][pRegularPlayer],PlayerInfo[playerid][pDj],PlayerInfo[playerid][pID]);
and for your first question: 100+ arguments crashed the compiler. "format" gives an error if I'm not wrong but you will never need that many arguments at once.
Reply
#8

i even tried your code and then this too still gives me
pawn Код:
mysql_format(g_SQL, query, sizeof(query), "UPDATE players SET admin=%d,owner=%d,scripter=%d WHERE id=%d LIMIT 1",
        PlayerInfo[playerid][pAdmin],PlayerInfo[playerid][pOwner],PlayerInfo[playerid][pScripter],PlayerInfo[playerid][pID]);
        mysql_tquery(g_SQL, query);
        mysql_format(g_SQL, query, sizeof(query), "UPDATE players SET donator=%d,regularplayer=%d,dj=%d WHERE id=%d LIMIT 1",
        PlayerInfo[playerid][pDonator],PlayerInfo[playerid][pRegularPlayer],PlayerInfo[playerid][pDj],PlayerInfo[playerid][pID]);
        mysql_tquery(g_SQL, query);//again on this line
same error
Reply
#9

Update stuff when it changes, rather than everything at once. And no, it won't stress your MySQL server.

For comparison: this forum runs MySQL. On average, for every page that is loaded 10 queries are executed. There are over 600 people online right now, so we can assume that 6,000 queries or more are executed every minute.
Reply
#10

This code will be added as player leaves.. updated then but why it is causing the problem ? I mean it's not that long still it gives the error.
And vince by this you mean i should be updating the data each time it's used not all together ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)