Help with saving function (MYSQL)
#1

Hi everyone, I'm working on a register system based in MYSQL. I've got the register and load function, but I need the saving function.

I'm trying to use this code, but it doesn't work.

pawn Код:
format(SQL,sizeof(SQL), "UPDATE Users SET Name='%s',Pass='%s',Nivel=%i,Level=%i,[...]WHERE ID = %i", PlayerInfo[playerid][pName],PlayerInfo[playerid][pKey],PlayerInfo[playerid][pLevel],PlayerInfo[playerid][pAdmin],[...],PlayerInfo[playerid][pMYSQLID]);
mysql_query(SQL);
mysql_free_result();
format(SQL2,sizeof(SQL2), "UPDATE Users SET [others variables][...]");
mysql_query(SQL2);
mysql_free_result();
;
I have to use two differents query's because of the amount of variables. (The lines is too long)
The first part works, (mysql_query(SQL), but the second doesn't work (SQL2).

Anyone know why? Thanks in advice.

(If someone knows a better way of saving variables with MYSQL tell me how please)

Sorry for my English.
Reply
#2

If the line is too long just use the "\" for the newline..
Example
pawn Код:
format(query, sizeof query, "UPDATE table SET variales \
WHERE a = 1"
);
Or, if the line of the variables is too long use
pawn Код:
format(query, sizeof query, "UPDATE [...]", variable1, variable2,
variable3, variable4);
Reply
#3

That is not my problem, I knew that, but when I've wrote many variables I get this error: "error 075: input line too long (after substitutions)". That is why I tried to update the stats in two parts.

Anyone have an answer?
Reply
#4

Did you look at mysql log file?
Reply
#5

Solved, the function didn't work because of a field named "Char". I don't know why but changing the name was enough to solve the problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)