Query input line too long and undefined symbol UPDATE
#10

Dude, what in the name of god are you doing? Formatting field names into the query? Where is the logic in that? Quick answer - there is none.

Please read the SA-MP wiki about these functions! strcat is not a substitute for format. The latter is used to format the string that you're going to strcat (in your case).

There are plenty of approaches to this:
1. Large formats! Laaaaarge formats!
pawn Код:
format(str, sizeof(str), "UPDATE playerdb SET stuff1=%d,stuff2=%d,stuff3=%d", stuff1, stuff2, stuff3);
format(str, sizeof(str), "%s,stuff4=%d,stuff5=%d,stuff6=%d", str, stuff4, stuff5, stuff6);
// ...
format(str, sizeof(str), "%s WHERE ... = ...", str);
Personally, I freak out when I see this, because I've ran some tests on this... and it is slow. And it gets slower the longer your string gets... damn!

2. Format a part and concatenate (strcat) it onto a larger buffer.
pawn Код:
new querybuffer[1024], oneline[128];
format(oneline, "UPDATE playerdb SET stuff1=%d,stuff2=%d,stuff3=%d", stuff1, stuff2, stuff3);
strcat(querybuffer, oneline);
format(oneline, ",stuff4=%d,stuff5=%d,stuff6=%d", stuff4, stuff5, stuff6);
strcat(querybuffer, oneline)
// ...
format(oneline, " WHERE ... = ...", ..., ...);
strcat(querybuffer, online);
// query
This is quite elegant when done correctly.

Please note that in the two last examples, I only made the script format _3_ fields in each format. In a real situation, I'd recommend to go as close to the line length limit as possible.

3. Use the modified compiler by Zeex. I don't know if I would recommend it seeing you're a beginner, but meh, it is a solution of some sort.

4. UPDATE DATA ONLY WHEN DATA NEEDS TO BE UPDATED!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)