SA-MP Forums Archive
MySQL incorrect line - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL incorrect line (/showthread.php?tid=422455)



MySQL incorrect line - dusk - 13.03.2013

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)



Re: MySQL incorrect line - Djole1337 - 13.03.2013

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


Re: MySQL incorrect line - fordawinzz - 13.03.2013

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.


Re: MySQL incorrect line - dusk - 13.03.2013

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?


Re: MySQL incorrect line - Misiur - 13.03.2013

new query2[64]; => new query2[128]


Re: MySQL incorrect line - dusk - 13.03.2013

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?


Re: MySQL incorrect line - Misiur - 13.03.2013

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);



Re: MySQL incorrect line - dusk - 29.03.2013

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)



Re: MySQL incorrect line - FunnyBear - 29.03.2013

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);



Re: MySQL incorrect line - dusk - 29.03.2013

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