PDA

View Full Version : MySQL R5 changing price, interior issue


Type-R
06/06/2014, 12:02 AM
Hey guys, well i have this house system for my freeroam server, and everything works fine, except for when i change the house interior(IN-GAME) with a dialog, the change of price, nor the ID of the interior do not save for some odd reason. The price of the house will save to 0, and interior always stays at 1.

heres a part of the script at the dialog:

if(dialogid == CInt)
{
new lString[256];
new hID = pInfo[playerid][CurrentHID];
// new hID = pInfo[playerid][CurrentHID]
//new hID = smasina[playerid];

if(!response)
{
ShowPlayerDialog(playerid, HMenu, DIALOG_STYLE_LIST, "House Menu", "(UN)Lock House\nChange Interior\nSell House\n", "Select", "Cancel");
}
if(response)
{
if(listitem == 0)
{
if(GetPlayerMoney(playerid) < 5000000) return SendClientMessage(playerid, COLOR_RED, "You don't have enough money to buy this interior!");
if(HouseInfo[hID][InteriorID] == 1) return SendClientMessage(playerid, COLOR_RED, "The current house interior is already the same!");
HouseInfo[hID][InteriorID] = 1;
HouseInfo[hID][Price] = 5000000;
format(gQuery, 256, "UPDATE `"Houses_Table"` SET `Price` = '%i', 'InteriorID' = '%i' WHERE `ID` = '%i'",HouseInfo[hID][Price], HouseInfo[hID][InteriorID], hID);
mysql_query(gQuery);
SendClientMessage(playerid, COLOR_GREEN, "Interior changed. Please re-enter your house!");
format(lString, sizeof(lString),"Namo Savininkas: %s\nNamo kaina: $%i\nNamas uzrakintas: %s", HouseInfo[hID][Owner], HouseInfo[hID][Price], (HouseInfo[hID][Locked] == 1) ? ("Taip") : ("Ne"));
UpdateDynamic3DTextLabelText(Text3D:HouseInfo[hID][Label], COLOR_RED, lString);
DestroyDynamicPickup(HouseInfo[hID][ExitPickup]);
SetHouseExit(playerid, hID);
KickFromHouse(playerid, hID);
}
if(listitem == 1)
{
if(GetPlayerMoney(playerid) < 4000000) return SendClientMessage(playerid, COLOR_RED, "You don't have enough money to buy this interior!");
if(HouseInfo[hID][InteriorID] == 2) return SendClientMessage(playerid, COLOR_RED, "The current house interior is already the same!");
HouseInfo[hID][InteriorID] = 2;
HouseInfo[hID][Price] = 4000000;
format(gQuery, 256, "UPDATE `"Houses_Table"` SET `Price` = '%i', 'InteriorID' = '%i' WHERE `ID` = '%i'",HouseInfo[hID][Price], HouseInfo[hID][InteriorID], hID);
mysql_query(gQuery);
SendClientMessage(playerid, COLOR_GREEN, "Interior changed. Please re-enter your house!");
format(lString, sizeof(lString),"Namo Savininkas: %s\nNamo kaina: $%i\nNamas uzrakintas: %s", HouseInfo[hID][Owner], HouseInfo[hID][Price], (HouseInfo[hID][Locked] == 1) ? ("Taip") : ("Ne"));
UpdateDynamic3DTextLabelText(Text3D:HouseInfo[hID][Label], COLOR_RED, lString);
DestroyDynamicPickup(HouseInfo[hID][ExitPickup]);
SetHouseExit(playerid, hID);
KickFromHouse(playerid, hID);
}

Heres the error line:

CMySQLHandler::Query(UPDATE `Houses` SET `Price` = 4000000, 'InteriorID ' = 2 WHERE `ID` = 5) - 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 ''InteriorID ' = 2 WHERE `ID` = 5' at line 1)

So the house is created to interior 1, and i try to change it to 2, it wont change. The prices becomes 0... Anyone know how to fix this? Thank you.

Type-R
06/06/2014, 02:15 PM
bump

Type-R
07/06/2014, 02:30 AM
Can anyone help me? I always get these stupid things, that seem to work in one part of the script, but not the other.

nmader
07/06/2014, 02:36 AM
Well, it sounds like perhaps the connection to the MySQL server may be lost. I've had this issue in the past.

biker122
07/06/2014, 07:21 AM
Would be good if you could show your mysql_log..

Type-R
07/06/2014, 02:57 PM
Crap, my mysql_log doesnt work for some reason, server doesnt create it in the server folder. Any thoughts on how i could fix that?

Type-R
07/06/2014, 03:10 PM
my bad got the mysql_log figured out, here the error line:

mysql_query( Connection handle: 1 )

[10:27:33] CMySQLHandler::Query(UPDATE `Houses` SET `Price` = 4000000, 'InteriorID' = 2 WHERE `ID` = 5) - 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 ''InteriorID' = 2 WHERE `ID` = 5' at line 1)


Any ideas?

Type-R
08/06/2014, 04:33 PM
bump

Type-R
09/06/2014, 03:11 PM
bump

Konstantinos
09/06/2014, 03:17 PM
Change 'InteriorID' to `InteriorID`.

Type-R
09/06/2014, 05:21 PM
Switched it, but the same thing:

CMySQLHandler::Query(UPDATE `Houses` SET `Price` = 4000000, 'InteriorID ' = 2 WHERE `ID` = 5) - 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 ''InteriorID ' = 2 WHERE `ID` = 5' at line 1)

Konstantinos
09/06/2014, 06:34 PM
You didn't, you still use apostrofes around InteriorID field: UPDATE `Houses` SET `Price` = 4000000, 'InteriorID ' = 2 WHERE `ID` = 5

Replace it with:

format(gQuery, 256, "UPDATE "Houses_Table" SET Price = %i, InteriorID = %i WHERE ID = %i",HouseInfo[hID][Price], HouseInfo[hID][InteriorID], hID);

Type-R
09/06/2014, 08:04 PM
Thanks man, it worked!