Array must be indexed -
dusk - 16.03.2013
The first problem.
Code:
pawn Код:
new query[128], labelstring[126];
format(labelstring,sizeof(labelstring),"Namas Parduodamas \n Kaina:%d \nNoredamas pirkti rasyk /buyhouse",HousePrice);
format(query,sizeof(query),"INSERT INTO houses (VirtualWorld,PosX,PosY,PosZ,Price,HouseLabel) VALUES (%d,%f,%f,%f,%d,%s)",GetPlayerVirtualWorld(playerid),x,y,z,HousePrice,labelstring);
mysql_query(query);
Error:
pawn Код:
[16:24:25] CMySQLHandler::Query(INSERT INTO houses (VirtualWorld,PosX,PosY,PosZ,Price,HouseLabel) VALUES (0,-205.562133,1032.921630,19.945363,420,Namas Parduod) - 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 'Parduod' at line 1)
And another problem:
pawn Код:
PlayerDrugs[playerid][Preke]+=1;
Error:
pawn Код:
C:\Users\Justas\Desktop\testserver 0.3x\gamemodes\rp.pwn(3251) : error 033: array must be indexed (variable "Preke")
The thing with this is I want to add "Preke" +1,but Preke is an item that players choose from a list. So i can not know which one do i need to add to.
Re: MySQL query does not work. Other thing:Array must be indexed -
Vince - 16.03.2013
Strings must appear between quotes in query like 'this'.
Second problem I don't know. Needs more information.
Re: MySQL query does not work. Other thing:Array must be indexed -
Scenario - 16.03.2013
Sort of off topic, but why are you saving the "labelstring" in the MySQL database? Wouldn't it just be easier to format the string when you create the house (or whatever it is you're trying to do)? Plus, it allows you to be more open to changes in the design of the label!
Not sure about the second problem, can you show where you're declaring PlayerDrugs?
Re: MySQL query does not work. Other thing:Array must be indexed -
Glad2BeHere - 16.03.2013
NB: added ' ' 'Namas Parduod' when ur writing a string raw u MUST add the ' '
Re: MySQL query does not work. Other thing:Array must be indexed -
dusk - 16.03.2013
pawn Код:
[17:45:27] CMySQLHandler::Query(INSERT INTO houses (VirtualWorld,PosX,PosY,PosZ,Price,HouseLabel) VALUES (0,-278.615264,1003.067810,20.939867,320,'Namas Parduo) - 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 ''Namas Parduo' at line 1)
Still the same error,although the line I changed:
pawn Код:
format(query,sizeof(query),"INSERT INTO houses (VirtualWorld,PosX,PosY,PosZ,Price,HouseLabel) VALUES (%d,%f,%f,%f,%d,'%s')",GetPlayerVirtualWorld(playerid),x,y,z,HousePrice,labelstring);
About the second thing, PlayerDrugs is an enum. "Preke" doesn't exist there.
Re: MySQL query does not work. Other thing:Array must be indexed -
kamzaf - 16.03.2013
Are you using R6 or R7?
Re: MySQL query does not work. Other thing:Array must be indexed -
dusk - 16.03.2013
I'm using R6.
Re: MySQL query does not work. Other thing:Array must be indexed -
kamzaf - 16.03.2013
ah R6 wont work like that this is how ur supposed to do it if im not wrong
pawn Код:
format(query,sizeof(query),"INSERT INTO `houses` (`VirtualWorld`,`PosX`,`PosY`,`PosZ`,`Price`,`HouseLabel`) VALUES ('%d','%f','%f','%f','%d','%s')",GetPlayerVirtualWorld(playerid),x,y,z,HousePrice,labelstring);
Re: MySQL query does not work. Other thing:Array must be indexed -
Scenario - 16.03.2013
Try escaping labelstring before sending it to the DB.
@kamzaf: You're wrong. You format the query the same way with both R6 and R7. The only difference between the two versions is that R7 REQUIRES the use of threaded queries.
Re: MySQL query does not work. Other thing:Array must be indexed -
dusk - 16.03.2013
Nop,the error changed tho:
pawn Код:
18:04:38] CMySQLHandler::Query(INSERT INTO `houses` (`VirtualWorld`,`PosX`,`PosY`,`PosZ`,`Price`,`HouseLabel`) VALUES ('0','-123.625144','917.415039','19.9376) - 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 ''19.9376' at line 1)
How do i escape it?