MySQL, input line too long
#1

ok, i get the errors what thay mean but how could i make the query in 2 lines, not in one?

pawn Code:
format(query, sizeof(query), "INSERT INTO playerdata (user, password, score, money, level, vip, kma, rank, kills, deaths, muted, jailed, frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins, cookies, warn1, warn2, warn3, warn1reason, warn2reason, warn3reason, dateregisterd, kickedtimes, restorepos, slapedtimes, posx, posy, posz, posa, IP) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', 017, 0, 0, 0, 0, 'No Warn', 'No Warn', 'No Warn', '%s', 0, 0, 0, 0, 0, 0, 0, '%s')", pname, passwordstring, Bannedby, ReggedDate, IP);
    mysql_query(query);
Code:
C:\Users\iMarkx\Desktop\CAS v5.0\gamemodes\CAS - Copy1.pwn(597) : error 075: input line too long (after substitutions)
C:\Users\iMarkx\Desktop\CAS v5.0\gamemodes\CAS - Copy1.pwn(598) : error 037: invalid string (possibly non-terminated string)
C:\Users\iMarkx\Desktop\CAS v5.0\gamemodes\CAS - Copy1.pwn(598) : error 017: undefined symbol "INSERT"
C:\Users\iMarkx\Desktop\CAS v5.0\gamemodes\CAS - Copy1.pwn(598) : error 017: undefined symbol "INTO"
C:\Users\iMarkx\Desktop\CAS v5.0\gamemodes\CAS - Copy1.pwn(598) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Reply
#2

This time you can do:

pawn Code:
format(query, sizeof(query),
    "INSERT INTO playerdata (user, password, score, money, level, vip, kma, rank, kills, deaths, muted, jailed, frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins, cookies, warn1, warn2, warn3, warn1reason, warn2reason, warn3reason, dateregisterd, kickedtimes, restorepos, slapedtimes, posx, posy, posz, posa, IP) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', 017, 0, 0, 0, 0, 'No Warn', 'No Warn', 'No Warn', '%s', 0, 0, 0, 0, 0, 0, 0, '%s')",
    pname, passwordstring, Bannedby, ReggedDate, IP);
But if you one day needs a even longer string then use https://sampwiki.blast.hk/wiki/Strpack .
Reply
#3

pawn Code:
format(query, sizeof(query), "INSERT INTO playerdata (user, password, score, money, level, vip, kma, rank, kills, deaths, muted, jailed, frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins,");
format(query, sizeof(query),  "%s cookies, warn1, warn2, warn3, warn1reason, warn2reason, warn3reason, dateregisterd, kickedtimes, restorepos, slapedtimes, posx, posy, posz, posa, IP)", query);
format(query, sizeof(query), "%s VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', 017, 0, 0, 0, 0, 'No Warn', 'No Warn', 'No Warn', '%s', 0, 0, 0, 0, 0, 0, 0, '%s')", query, pname, passwordstring, Bannedby, ReggedDate, IP);
Doing that should fix it.
Reply
#4

Quote:
Originally Posted by [HiC]TheKiller
View Post
pawn Code:
format(query, sizeof(query), "INSERT INTO playerdata (user, password, score, money, level, vip, kma, rank, kills, deaths, muted, jailed, frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins,");
format(query, sizeof(query),  "%s cookies, warn1, warn2, warn3, warn1reason, warn2reason, warn3reason, dateregisterd, kickedtimes, restorepos, slapedtimes, posx, posy, posz, posa, IP)", query);
format(query, sizeof(query), "%s VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', 017, 0, 0, 0, 0, 'No Warn', 'No Warn', 'No Warn', '%s', 0, 0, 0, 0, 0, 0, 0, '%s')", query, pname, passwordstring, Bannedby, ReggedDate, IP);
Doing that should fix it.
Format is for formating only! Use https://sampwiki.blast.hk/wiki/Strpack instead. Also he doesn't need to do that at all becouse the string isn't so long so you can just do like my first post in here.
Reply
#5

Quote:
Originally Posted by robanswe
View Post
Format is for formating only! Use https://sampwiki.blast.hk/wiki/Strpack instead. Also he doesn't need to do that at all becouse the string isn't so long so you can just do like my first post in here.
Actually, he is formatting the string.

Also, in the case you should concatenate the string, not pack it: https://sampwiki.blast.hk/wiki/Strcat
Reply
#6

pawn Code:
format(query, sizeof(query), "INSERT INTO playerdata (user, password, score, money, level, vip, kma, rank, kills, deaths, muted, jailed, frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins, cookies, warn1, warn2, warn3, warn1reason, warn2reason, warn3reason, dateregisterd, kickedtimes, restorepos, slapedtimes, posx, posy, posz, posa, IP) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', 017, 0, 0, 0, 0, 'No Warn', 'No Warn', 'No Warn', '%s', 0, 0, 0, 0, 0, 0, 0, '%s'", pname, passwordstring, Bannedby, ReggedDate, IP);
Reply
#7

Quote:
Originally Posted by Grim_
View Post
Actually, he is formatting the string.

Also, in the case you should concatenate the string, not pack it: https://sampwiki.blast.hk/wiki/Strcat
I fail it was strcat I was going to send.
Reply
#8

Alright, both rep+
Reply
#9

If you're still interested there's another way. Just add '\' where you go to a new line:
pawn Code:
format(query, sizeof(query),
    "INSERT INTO playerdata (user, password, score, money, level, vip, kma, rank, kills, deaths, muted, jailed, \
    frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins, cookies, warn1, warn2, warn3, \
    warn1reason, warn2reason, warn3reason, dateregisterd, kickedtimes, restorepos, slapedtimes, posx, posy, \
    posz, posa, IP) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', 017, 0, 0, 0, \
    0, 'No Warn', 'No Warn', 'No Warn', '%s', 0, 0, 0, 0, 0, 0, 0, '%s')"
,
pname, passwordstring, Bannedby, ReggedDate, IP);
mysql_query(query);
Reply
#10

Quote:
Originally Posted by RyDeR`
View Post
If you're still interested there's another way. Just add '\' where you go to a new line:
pawn Code:
format(query, sizeof(query),
    "INSERT INTO playerdata (user, password, score, money, level, vip, kma, rank, kills, deaths, muted, jailed, \
    frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins, cookies, warn1, warn2, warn3, \
    warn1reason, warn2reason, warn3reason, dateregisterd, kickedtimes, restorepos, slapedtimes, posx, posy, \
    posz, posa, IP) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', 017, 0, 0, 0, \
    0, 'No Warn', 'No Warn', 'No Warn', '%s', 0, 0, 0, 0, 0, 0, 0, '%s')"
,
pname, passwordstring, Bannedby, ReggedDate, IP);
mysql_query(query);
Wow thanks a lot that will speed up the query writing speed for sure.

+rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)