MySQL incorrect line
#1

My query line is wrong,and I just can not find the problem,can you?
pawn Код:
format(query2,sizeof(query2),"UPDATE Drugs SET Receptai = 0, '%s' = 1 WHERE Username = '%s'",Preke,Name);
pawn Код:
:30] CMySQLHandler::Query(UPDATE Drugs SET Receptai = 0, 'Ambroxolis' = 1 WHERE Username ) - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Ambroxolis' = 1 WHERE Username' at line 1)
Reply
#2

pawn Код:
%s = '1'
Can you tell me what is that ?
Reply
#3

pawn Код:
format(query2,sizeof(query2),"UPDATE `Drugs` SET Receptai = 0, %s = 1 WHERE Username = '%s'",Preke,Name);
fields must be used without " ' ", these are only for strings.

you can use " ` " for fields and for tables.
Reply
#4

nop..the problem is still there:
pawn Код:
[22:27:57] CMySQLHandler::Query(UPDATE `Drugs` SET Receptai = 0, Ambroxolis = 1 WHERE Username ) - Successfully executed.
One thing i noticed is, it should update bla bla bla WHERE username = '%s',but in the log it says WHERE username and nothing,here's a bit more of the script
pawn Код:
GivePlayerMoney(playerid,-Kaina);
                    PlayerInfo[playerid][money]-=Kaina;
                    new query2[64];
                    GetPlayerName(playerid,Name,sizeof(Name));
                    format(query2,sizeof(query2),"UPDATE `Drugs` SET Receptai = 0, %s = 1 WHERE Username = '%s'",Preke,Name);
                    mysql_query(query2);
I get the player's name,what is the problem?
Reply
#5

new query2[64]; => new query2[128]
Reply
#6

I would have never though of that, i thank you.

Any chance you know how do i add to the value in mysql? I mean would
pawn Код:
format(query2,sizeof(query2),"UPDATE `Drugs` SET Receptai = 0, %s = +1 WHERE Username = '%s'",Preke,Name);
work?
Reply
#7

Nope

Quote:

UPDATE `Drugs` SET Receptai = 0, %s = %s + 1 WHERE Username = '%s'

#e:
pawn Код:
format(query2,sizeof(query2),"UPDATE `Drugs` SET Receptai = 0, %s = %s +1 WHERE Username = '%s'",Preke,Preke,Name);
Reply
#8

Hello,i decided to post my problem here and not create a new thread.

Line:
pawn Код:
format(query,sizeof(query),"INSERT INTO `houses` (Price,enX,enY,enZ,exX,exY,exZ,Interior) VALUES (%d,%f,%f,%f,%f,%f,%f,%d)",tmp,PosX,PosY,PosZ,x,y,z,tmp2);
Error:
pawn Код:
[09:39:32] CMySQLHandler::Query(INSERT INTO `houses` (Price,enX,enY,enZ,exX,exY,exZ,Interior) VALUES (50000,-185.327911,965.026733,18.267084,140.169998,1366.06) - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1)
Reply
#9

Change it to this:

pawn Код:
format(query,sizeof(query),"INSERT INTO houses (Price, enX, enY, enZ, exX, exY, exZ, Interior) VALUES('%d', '%f', '%f', '%f', '%f', '%f', '%f', '%d')", tmp, PosX, PosY, PosZ, x, y, z, tmp2);
Reply
#10

Nop,doesn't work
pawn Код:
format(query,sizeof(query),"INSERT INTO houses (Price, enX, enY, enZ, exX, exY, exZ, Interior) VALUES('%d', '%f', '%f', '%f', '%f', '%f', '%f', '%d')", tmp, PosX, PosY, PosZ, x, y, z, tmp2);
PHP код:
[10:36:17CMySQLHandler::Query(INSERT INTO houses (PriceenXenYenZexXexYexZInteriorVALUES('40000''-186.226043''964.828674''18.233377''1) - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1' at line 1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)