SA-MP Forums Archive
MySQL Query Error - Help-me - 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 Query Error - Help-me (/showthread.php?tid=410493)



MySQL Query Error - Help-me - Strike_Legends - 25.01.2013

Hello, can anyone help me solve this error?

Script Code:
PHP код:
SaveHouses(const id){
   if(
strlen(HouseInfo[id][hOwner]) >= 1)
   {
        
format(szLargeStringsizeof(szLargeString), "UPDATE houses SET Level = '%d', InteriorWorld = '%d', Description = '%s', Dono = '%s', ExteriorX = '%f', ExteriorY = '%f', ExteriorZ = '%f', ExteriorR = '%f', InteriorX = '%f', InteriorY = '%f', InteriorZ = '%f', InteriorR = '%f'",
        
HouseInfo[id][hLevel], HouseInfo[id][hHInteriorWorld], HouseInfo[id][hDescription], HouseInfo[id][hOwner], HouseInfo[id][hExteriorX], HouseInfo[id][hExteriorY], HouseInfo[id][hExteriorZ], HouseInfo[id][hExteriorR], HouseInfo[id][hInteriorX], HouseInfo[id][hInteriorY], HouseInfo[id][hInteriorZ], HouseInfo[id][hInteriorR]);
          
format(szLargeStringsizeof(szLargeString), "%s, Lock = '%d', Rentable = '%d', Rentfee = '%d', Valor = '%d', SafeMoney = '%d'",szLargeStringHouseInfo[id][hLock], HouseInfo[id][hRentable], HouseInfo[id][hRentFee], HouseInfo[id][hValue], HouseInfo[id][hSafeMoney]);
          
format(szLargeStringsizeof(szLargeString), "%s, Pot = '%d', Crack = '%d', Materials = '%d', Weapons1 = '%d', Weapons2 = '%d', Weapons3 = '%d', Weapons4 = '%d', Weapons5 = '%d'",szLargeStringHouseInfo[id][hPot], HouseInfo[id][hCrack], HouseInfo[id][hMaterials], HouseInfo[id][hWeapons][0], HouseInfo[id][hWeapons][1], HouseInfo[id][hWeapons][2], HouseInfo[id][hWeapons][3], HouseInfo[id][hWeapons][4]);
          
format(szLargeStringsizeof(szLargeString), "%s, GLUpgrade = '%d', PickupID = '%d', CustomInterior = '%d', CustomExterior = '%d', ExteriorA = '%f', InteriorA = '%f' WHERE hID = '%d'"szLargeStringHouseInfo[id][hGLUpgrade], HouseInfo[id][hPickupID], HouseInfo[id][hCustomInterior], HouseInfo[id][hCustomExterior], HouseInfo[id][hExteriorA], HouseInfo[id][hInteriorA], id);
        
mysql_query(szLargeString);
    }
    else {
        return 
false;
    }
    return 
1;

Debug Log
Код:
[18:28:15] CMySQLHandler::Query(resultID) - Threaded query with id 2 started. (Extra ID: 0)

[18:28:15] CMySQLHandler::ProcessQueryThread() - Error will be triggered to OnQueryError()

[18:28:15] OnQueryError() - Called.

[18:28:49] >> mysql_query( Connection handle: 1 )

[18:28:49] CMySQLHandler::Query(UPDATE houses SET Level = '0', InteriorWorld = '0', Description = '(null)', Dono = '(null)', ExteriorX = '1526.401367', ExteriorY = '-1675.587646', ExteriorZ = '13.382812', ExteriorR = '0.000000', InteriorX = '0.000000', InteriorY = '0.000000', InteriorZ = '0.000000', InteriorR = '0.000000', Lock = '0', Rentable = '0', Rentfee = '0', Valor = '0', SafeMoney = '0', Pot = '0', Crack = '0', Materials = '0', Weapons1 = '0', Weapons2 = '0', Weapons3 = '0', Weapons4 = '0', Weapons5 = '0', GLUpgrade = '0', PickupID = '136', CustomInterior = '0', CustomExterior = '0', ExteriorA = '159.985794', InteriorA = '0.000000' WHERE hID = '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 'Lock = '0', Rentable = '0', Rentfee = '0', Valor = '0', SafeMoney = '0', Pot = '' at line 1)

[18:28:49] >> mysql_query( Connection handle: 1 )

[18:28:49] CMySQLHandler::Query(UPDATE houses SET Level = '0', InteriorWorld = '0', Description = '(null)', Dono = '(null)', ExteriorX = '1526.401367', ExteriorY = '-1675.587646', ExteriorZ = '13.382812', ExteriorR = '0.000000', InteriorX = '0.000000', InteriorY = '0.000000', InteriorZ = '0.000000', InteriorR = '0.000000', Lock = '0', Rentable = '0', Rentfee = '0', Valor = '0', SafeMoney = '0', Pot = '0', Crack = '0', Materials = '0', Weapons1 = '0', Weapons2 = '0', Weapons3 = '0', Weapons4 = '0', Weapons5 = '0', GLUpgrade = '0', PickupID = '136', CustomInterior = '0', CustomExterior = '0', ExteriorA = '159.985794', InteriorA = '0.000000' WHERE hID = '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 'Lock = '0', Rentable = '0', Rentfee = '0', Valor = '0', SafeMoney = '0', Pot = '' at line 1)

[18:28:49] OnQueryError() - Called.

[18:28:49] OnQueryError() - Called.
QueryDump Log
Код:
[2013/1/25 - 18:40:51] UPDATE houses SET Level = '0', InteriorWorld = '0', Description = '(null)', Dono = '(null)', ExteriorX = '1519.109130', ExteriorY = '-1697.128540', ExteriorZ = '13.546875', ExteriorR = '0.000000', InteriorX = '0.000000', InteriorY = '0.000000', InteriorZ = '0.000000', InteriorR = '0.000000', Lock = '0', Rentable = '0', Rentfee = '0', Valor = '0', SafeMoney = '0', Pot = '0', Crack = '0', Materials = '0', Weapons1 = '0', Weapons2 = '0', Weapons3 = '0', Weapons4 = '0', Weapons5 = '0', GLUpgrade = '0', PickupID = '137', CustomInterior = '0', CustomExterior = '0', ExteriorA = '279.968963', InteriorA = '0.000000' WHERE hID = '2'
Tables created by navicat.
Код:
DROP TABLE IF EXISTS `houses`;
CREATE TABLE `houses` (
  `hID` int(11) NOT NULL AUTO_INCREMENT,
  `Level` int(11) NOT NULL DEFAULT '0',
  `InteriorWorld` int(11) NOT NULL DEFAULT '0',
  `Description` varchar(256) NOT NULL DEFAULT '(null)',
  `Dono` varchar(256) NOT NULL DEFAULT '(null)',
  `ExteriorX` varchar(256) NOT NULL DEFAULT '0.000000',
  `ExteriorY` varchar(256) NOT NULL DEFAULT '0.000000',
  `ExteriorZ` varchar(256) NOT NULL DEFAULT '0.000000',
  `ExteriorR` varchar(256) NOT NULL DEFAULT '0.000000',
  `InteriorX` varchar(256) NOT NULL DEFAULT '0.000000',
  `InteriorY` varchar(256) NOT NULL DEFAULT '0.000000',
  `InteriorZ` varchar(256) NOT NULL DEFAULT '0.000000',
  `InteriorR` varchar(256) NOT NULL DEFAULT '0.000000',
  `Lock` int(11) NOT NULL DEFAULT '0',
  `Rentable` int(11) NOT NULL DEFAULT '0',
  `Rentfee` int(11) NOT NULL DEFAULT '0',
  `Valor` int(11) NOT NULL DEFAULT '0',
  `SafeMoney` int(11) NOT NULL DEFAULT '0',
  `Pot` int(11) NOT NULL DEFAULT '0',
  `Crack` int(11) NOT NULL DEFAULT '0',
  `Materials` int(11) NOT NULL DEFAULT '0',
  `Weapons1` int(11) NOT NULL DEFAULT '0',
  `Weapons2` int(11) NOT NULL DEFAULT '0',
  `Weapons3` int(11) NOT NULL DEFAULT '0',
  `Weapons4` int(11) NOT NULL DEFAULT '0',
  `Weapons5` int(11) NOT NULL DEFAULT '0',
  `GLUpgrade` int(11) NOT NULL DEFAULT '0',
  `PickupID` int(11) NOT NULL DEFAULT '0',
  `CustomInterior` int(11) NOT NULL DEFAULT '0',
  `CustomExterior` int(11) NOT NULL DEFAULT '0',
  `InteriorA` varchar(256) NOT NULL DEFAULT '0.000000',
  `ExteriorA` varchar(256) NOT NULL DEFAULT '0.000000',
  PRIMARY KEY (`hID`)
) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=latin1;
Server_Log
Код:
[18:40:51] [MySQL] Query Error - (Thread: -1) (ExtraID: -1) (ErrorID: 1064)
[18:40:51] [MySQL] Check /logs/querydump.log to review the query that threw the error.
[18:40:51] [MySQL] Query Error - (Thread: -1) (ExtraID: -1) (ErrorID: 1064)
[18:40:51] [MySQL] Check /logs/querydump.log to review the query that threw the error.



Re: MySQL Erro - IPrototypeI - 25.01.2013

Quote:
Originally Posted by Strike_Legends
Посмотреть сообщение
Hello, can anyone help me solve this error?

Script Code:
PHP код:
SaveHouses(const id){
   if(
strlen(HouseInfo[id][hOwner]) >= 1)
   {
        
format(szLargeStringsizeof(szLargeString), "UPDATE houses SET Level = '%d', InteriorWorld = '%d', Description = '%s', Dono = '%s', ExteriorX = '%f', ExteriorY = '%f', ExteriorZ = '%f', ExteriorR = '%f', InteriorX = '%f', InteriorY = '%f', InteriorZ = '%f', InteriorR = '%f'",
        
HouseInfo[id][hLevel], HouseInfo[id][hHInteriorWorld], HouseInfo[id][hDescription], HouseInfo[id][hOwner], HouseInfo[id][hExteriorX], HouseInfo[id][hExteriorY], HouseInfo[id][hExteriorZ], HouseInfo[id][hExteriorR], HouseInfo[id][hInteriorX], HouseInfo[id][hInteriorY], HouseInfo[id][hInteriorZ], HouseInfo[id][hInteriorR]);
          
format(szLargeStringsizeof(szLargeString), "%s, Lock = '%d', Rentable = '%d', Rentfee = '%d', Valor = '%d', SafeMoney = '%d'",szLargeStringHouseInfo[id][hLock], HouseInfo[id][hRentable], HouseInfo[id][hRentFee], HouseInfo[id][hValue], HouseInfo[id][hSafeMoney]);
          
format(szLargeStringsizeof(szLargeString), "%s, Pot = '%d', Crack = '%d', Materials = '%d', Weapons1 = '%d', Weapons2 = '%d', Weapons3 = '%d', Weapons4 = '%d', Weapons5 = '%d'",szLargeStringHouseInfo[id][hPot], HouseInfo[id][hCrack], HouseInfo[id][hMaterials], HouseInfo[id][hWeapons][0], HouseInfo[id][hWeapons][1], HouseInfo[id][hWeapons][2], HouseInfo[id][hWeapons][3], HouseInfo[id][hWeapons][4]);
          
format(szLargeStringsizeof(szLargeString), "%s, GLUpgrade = '%d', PickupID = '%d', CustomInterior = '%d', CustomExterior = '%d', ExteriorA = '%f', InteriorA = '%f' WHERE hID = '%d'"szLargeStringHouseInfo[id][hGLUpgrade], HouseInfo[id][hPickupID], HouseInfo[id][hCustomInterior], HouseInfo[id][hCustomExterior], HouseInfo[id][hExteriorA], HouseInfo[id][hInteriorA], id);
        
mysql_query(szLargeString);
    }
    else {
        return 
false;
    }
    return 
1;

Debug Log
Код:
[18:28:15] CMySQLHandler::Query(resultID) - Threaded query with id 2 started. (Extra ID: 0)

[18:28:15] CMySQLHandler::ProcessQueryThread() - Error will be triggered to OnQueryError()

[18:28:15] OnQueryError() - Called.

[18:28:49] >> mysql_query( Connection handle: 1 )

[18:28:49] CMySQLHandler::Query(UPDATE houses SET Level = '0', InteriorWorld = '0', Description = '(null)', Dono = '(null)', ExteriorX = '1526.401367', ExteriorY = '-1675.587646', ExteriorZ = '13.382812', ExteriorR = '0.000000', InteriorX = '0.000000', InteriorY = '0.000000', InteriorZ = '0.000000', InteriorR = '0.000000', Lock = '0', Rentable = '0', Rentfee = '0', Valor = '0', SafeMoney = '0', Pot = '0', Crack = '0', Materials = '0', Weapons1 = '0', Weapons2 = '0', Weapons3 = '0', Weapons4 = '0', Weapons5 = '0', GLUpgrade = '0', PickupID = '136', CustomInterior = '0', CustomExterior = '0', ExteriorA = '159.985794', InteriorA = '0.000000' WHERE hID = '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 'Lock = '0', Rentable = '0', Rentfee = '0', Valor = '0', SafeMoney = '0', Pot = '' at line 1)

[18:28:49] >> mysql_query( Connection handle: 1 )

[18:28:49] CMySQLHandler::Query(UPDATE houses SET Level = '0', InteriorWorld = '0', Description = '(null)', Dono = '(null)', ExteriorX = '1526.401367', ExteriorY = '-1675.587646', ExteriorZ = '13.382812', ExteriorR = '0.000000', InteriorX = '0.000000', InteriorY = '0.000000', InteriorZ = '0.000000', InteriorR = '0.000000', Lock = '0', Rentable = '0', Rentfee = '0', Valor = '0', SafeMoney = '0', Pot = '0', Crack = '0', Materials = '0', Weapons1 = '0', Weapons2 = '0', Weapons3 = '0', Weapons4 = '0', Weapons5 = '0', GLUpgrade = '0', PickupID = '136', CustomInterior = '0', CustomExterior = '0', ExteriorA = '159.985794', InteriorA = '0.000000' WHERE hID = '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 'Lock = '0', Rentable = '0', Rentfee = '0', Valor = '0', SafeMoney = '0', Pot = '' at line 1)

[18:28:49] OnQueryError() - Called.

[18:28:49] OnQueryError() - Called.
QueryDump Log
Код:
[2013/1/25 - 18:40:51] UPDATE houses SET Level = '0', InteriorWorld = '0', Description = '(null)', Dono = '(null)', ExteriorX = '1519.109130', ExteriorY = '-1697.128540', ExteriorZ = '13.546875', ExteriorR = '0.000000', InteriorX = '0.000000', InteriorY = '0.000000', InteriorZ = '0.000000', InteriorR = '0.000000', Lock = '0', Rentable = '0', Rentfee = '0', Valor = '0', SafeMoney = '0', Pot = '0', Crack = '0', Materials = '0', Weapons1 = '0', Weapons2 = '0', Weapons3 = '0', Weapons4 = '0', Weapons5 = '0', GLUpgrade = '0', PickupID = '137', CustomInterior = '0', CustomExterior = '0', ExteriorA = '279.968963', InteriorA = '0.000000' WHERE hID = '2'
Tables created by navicat.
Код:
DROP TABLE IF EXISTS `houses`;
CREATE TABLE `houses` (
  `hID` int(11) NOT NULL AUTO_INCREMENT,
  `Level` int(11) NOT NULL DEFAULT '0',
  `InteriorWorld` int(11) NOT NULL DEFAULT '0',
  `Description` varchar(256) NOT NULL DEFAULT '(null)',
  `Dono` varchar(256) NOT NULL DEFAULT '(null)',
  `ExteriorX` varchar(256) NOT NULL DEFAULT '0.000000',
  `ExteriorY` varchar(256) NOT NULL DEFAULT '0.000000',
  `ExteriorZ` varchar(256) NOT NULL DEFAULT '0.000000',
  `ExteriorR` varchar(256) NOT NULL DEFAULT '0.000000',
  `InteriorX` varchar(256) NOT NULL DEFAULT '0.000000',
  `InteriorY` varchar(256) NOT NULL DEFAULT '0.000000',
  `InteriorZ` varchar(256) NOT NULL DEFAULT '0.000000',
  `InteriorR` varchar(256) NOT NULL DEFAULT '0.000000',
  `Lock` int(11) NOT NULL DEFAULT '0',
  `Rentable` int(11) NOT NULL DEFAULT '0',
  `Rentfee` int(11) NOT NULL DEFAULT '0',
  `Valor` int(11) NOT NULL DEFAULT '0',
  `SafeMoney` int(11) NOT NULL DEFAULT '0',
  `Pot` int(11) NOT NULL DEFAULT '0',
  `Crack` int(11) NOT NULL DEFAULT '0',
  `Materials` int(11) NOT NULL DEFAULT '0',
  `Weapons1` int(11) NOT NULL DEFAULT '0',
  `Weapons2` int(11) NOT NULL DEFAULT '0',
  `Weapons3` int(11) NOT NULL DEFAULT '0',
  `Weapons4` int(11) NOT NULL DEFAULT '0',
  `Weapons5` int(11) NOT NULL DEFAULT '0',
  `GLUpgrade` int(11) NOT NULL DEFAULT '0',
  `PickupID` int(11) NOT NULL DEFAULT '0',
  `CustomInterior` int(11) NOT NULL DEFAULT '0',
  `CustomExterior` int(11) NOT NULL DEFAULT '0',
  `InteriorA` varchar(256) NOT NULL DEFAULT '0.000000',
  `ExteriorA` varchar(256) NOT NULL DEFAULT '0.000000',
  PRIMARY KEY (`hID`)
) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=latin1;
Server_Log
Код:
[18:40:51] [MySQL] Query Error - (Thread: -1) (ExtraID: -1) (ErrorID: 1064)
[18:40:51] [MySQL] Check /logs/querydump.log to review the query that threw the error.
[18:40:51] [MySQL] Query Error - (Thread: -1) (ExtraID: -1) (ErrorID: 1064)
[18:40:51] [MySQL] Check /logs/querydump.log to review the query that threw the error.
you have an error in your Sql Syntax.
You have to check your code but i don't found any mistake or my eyes are bad

PHP код:
        format(szLargeStringsizeof(szLargeString), "UPDATE `houses` SET `Level` = '%d', `InteriorWorld` = '%d', `Description` = '%s', `Dono` = '%s', `ExteriorX` = '%f', `ExteriorY` = '%f', `ExteriorZ` = '%f', `ExteriorR` = '%f', `InteriorX` = '%f', `InteriorY` = '%f', `InteriorZ` = '%f', `InteriorR` = '%f'",
        
HouseInfo[id][hLevel], HouseInfo[id][hHInteriorWorld], HouseInfo[id][hDescription], HouseInfo[id][hOwner], HouseInfo[id][hExteriorX], HouseInfo[id][hExteriorY], HouseInfo[id][hExteriorZ], HouseInfo[id][hExteriorR], HouseInfo[id][hInteriorX], HouseInfo[id][hInteriorY], HouseInfo[id][hInteriorZ], HouseInfo[id][hInteriorR]);
        
format(szLargeStringsizeof(szLargeString), "%s, `Lock` = '%d', `Rentable` = '%d', `Rentfee` = '%d', `Valor` = '%d', `SafeMoney` = '%d'",szLargeStringHouseInfo[id][hLock], HouseInfo[id][hRentable], HouseInfo[id][hRentFee], HouseInfo[id][hValue], HouseInfo[id][hSafeMoney]);
        
format(szLargeStringsizeof(szLargeString), "%s, `Pot` = '%d', `Crack` = '%d', `Materials` = '%d', `Weapons1` = '%d', `Weapons2` = '%d', `Weapons3` = '%d', `Weapons4` = '%d', `Weapons5` = '%d'",szLargeStringHouseInfo[id][hPot], HouseInfo[id][hCrack], HouseInfo[id][hMaterials], HouseInfo[id][hWeapons][0], HouseInfo[id][hWeapons][1], HouseInfo[id][hWeapons][2], HouseInfo[id][hWeapons][3], HouseInfo[id][hWeapons][4]);
        
format(szLargeStringsizeof(szLargeString), "%s, `GLUpgrade` = '%d', `PickupID` = '%d', `CustomInterior` = '%d', `CustomExterior` = '%d', `ExteriorA` = '%f', `InteriorA` = '%f' WHERE `hID` = '%d'"szLargeStringHouseInfo[id][hGLUpgrade], HouseInfo[id][hPickupID], HouseInfo[id][hCustomInterior], HouseInfo[id][hCustomExterior], HouseInfo[id][hExteriorA], HouseInfo[id][hInteriorA], id);
        
mysql_query(szLargeString); 
But use I give you an advice use backtricks (`) they are very important for table name or column names because mysql even use reserved words (keywords) and to use no command instead of the calling tables or columns.