[MySQL] Input line too long
#1

Fixed.
Reply
#2

When I have a string that is too long I usually split it into several pieces and then use strcat to make them into one big string.
pawn Код:
new string[500]; //should be big enough
format(string, sizeof string, "long text 1 here");
strcat(string, "this text will be added to 'string' ");
strcat(string, "this text will be added to the new string (which contains the text above)");
//then here you use "string" instead of your long text (as "string" now contains all the text)
Reply
#3

Execute multiple queries or use strcat. But here's a tip: In MySQL you can set default values for nearly everything, even the registration date. When these are all set, the only thing you need to do is:

pawn Код:
format(query, sizeof(query), "INSERT INTO playerdata (user, password) VALUES ('%s', '%s')", pname, passwordstring);
Reply
#4

Heard of that method but didnt try it, lol, lets see if it works...

EDIT: can someone post the working code? Im confused.
Reply
#5

pawn Код:
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, warns, warn1reason, warn2reason, warn3reason, recordkillsteak, registerdate, laston, posx, \
    posy, posz, posa, IP"
);
format(query, sizeof(query), "VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', 0, 0, 0, \ //Error line
    'N/A', 'N/A', 'N/A', '%s', '%s', 0, 0, 0, 0, '%s')"
, pname, passwordstring, Bannedby, ReggDate, LastOn, IP);
adn in mysql_query use query, mysql_query(query);
Reply
#6

Quote:
Originally Posted by System64
Посмотреть сообщение
pawn Код:
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, warns, warn1reason, warn2reason, warn3reason, recordkillsteak, registerdate, laston, posx, \
    posy, posz, posa, IP"
);
format(query, sizeof(query), "VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', 0, 0, 0, \ //Error line
    'N/A', 'N/A', 'N/A', '%s', '%s', 0, 0, 0, 0, '%s')"
, pname, passwordstring, Bannedby, ReggDate, LastOn, IP);
adn in mysql_query use query, mysql_query(query);
That code fails, but thanks anyway.

STRCAT is freaking confusing, can someone post a working code with it?

EDIT: Nevermind it works. I fail, lol. It compiles
Reply
#7

Use Vince's answer and fill in the columns with default values. That way, you can only insert username and pass, everything else is autofilled with values you specify.
Reply
#8

You can't have default values for text fields though iirc
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)