MYSQL INSERT INTO
#1

why this code doesn't works.. i can't compile..
Код:
format(query, sizeof(query), "INSERT INTO `users` (name, password, cash, admin, tester, kills, deaths, registered, sex, skin, age, banned, warns, origin, muted, mutetime, carlic, lictests, FStyle, jailed, jailtime, resttime, note1, note1s, note2, note2s, note3, note3s, note4, note4s, note5, note5s) VALUES (\'%s\', \'%s\', \'%d\', \'%d\', \'%d\', \'%d\', \'%d\', \'%d\', \'%d\', \'%d\', \'%d\', \'%d\', \'%d\', \'%s\', \'%d\', \'%d\', \'%d\', \'%d\', \'%d\', \'%d\', \'%d\', \'%d\', \'%d\', \'%s\', \'%d\', \'%s\', \'%d\', \'%s\', \'%d\', \'%s\', \'%d\', \'%s\')",
it's half of the code, the error is:
rp.pwn(9426) : error 075: input line too long (after substitutions)
rp.pwn(9427) : error 027: invalid character constant
rp.pwn(9427) : error 017: undefined symbol "INSERT"
rp.pwn(9427) : error 017: undefined symbol "INTO"
Reply
#2

Divide the line into two parts, as it says 'input line is tooo long.'
What is ' \ ' because I don't know it! (I am sorry if it's valid.)
Reply
#3

@Rajat_Pawar: It's not needed in the code above. However, some people prefer to make this functions like this:
FUNCTION('string data');
And you can use:
FUNCTION("string data");
Do you see the differences? The ' and the ".
When you use the ' to make this, using that character again would mean that the string is ended, like this:
FUNCTION('string data '1' '2'');
This would mean that the string would stop reading here:
FUNCTION ('string data '
Then you'll get errors. However, when you use \', it will be calculated as a normal ' so that this won't happen. But PaulDiman used it like this: FUNCTION("string data"); so it's not needed (as far as I know)

I hope you understood that because I have no idea how to explain it else.
Reply
#4

Alright, got it. ' ends it. \' ends the 'part' and keeps it going on. Thanks!
Reply
#5

That's correct. Just like the \ - If you use that one only, it indicates that the code is continueing on the line below (eg.):
Код:
#define something(%0, %1) printf("%d", (%0 + %1)); print("I just calculated something :D");
//Is the same as:
#define something(%0, %1) printf("%d", (%0 + %1)); \
print("I just calculated something :D");
So if you want to use the slash \, you must do this double slash;
Код:
print("This is a slash: \\"); //Will print: This is a slash: \
Kind Regards,
Kwarde
Reply
#6

Or either use strcat();

Like:
pawn Код:
new
     iStr[1024]
;
strcat(iStr, "something1... ");
strcat(iStr, "something2... ");
Now you can do query or w/e you want.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)