Error in a MySQL query.
#1

Hey, 30 minutes so far, i've been staring at this query and figuring out what's wrong with it. It used to work, now it just randomly stopped.

What I know
- The problem doesn't involve the size of the string.
- The query in the MySQL log returns: [code=MySQL Log]CMySQLHandler::Query(UPDATE Vehicles SET Model=0, X='0.000000',Y='0.000000',Z='0.000000',Angle='0.00 0000',Color1=0,Color2=0,Mod1=0,Mod2=0,Mod3=0,Mod4= 0,Mod5=0,Mod6=0,Mod7=0,Mod8=0,Mod9=0,Mod10=0,Mod11 =0,Mod12=0,Mod13=0,Range='0.000000',Health='0.0000 00',Owner='None',Type=0,RentPrice=0,Price=0,Fuel=0 ,Faction=0,Job=0,Buyable=0,Locked=0,Rentable=0, ParkX='0.000000',ParkY='0.000000',ParkZ='0.000000' ,ParkAngle='0.000000',fCarID=0 WHERE vehicleid = 3) - 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 'Range='0.000000',Health='0.000000',Owner='None',T ype=0,RentPrice=0,Price=0,Fuel=' at line 1)[/code]

Anyway, the function with the query is below, maybe my eyes are messed up or i'm not reading carefully or working carefully.

pawn Код:
function SaveVehicle(vehicleid) {
    new string[620];
    format(string, sizeof(string), "UPDATE Vehicles SET Model=%d, X='%f',Y='%f',Z='%f',Angle='%f',Color1=%d,Color2=%d,Mod1=%d,Mod2=%d,Mod3=%d,Mod4=%d,Mod5=%d,Mod6=%d,Mod7=%d,Mod8=%d,Mod9=%d,Mod10=%d,Mod11=%d,Mod12=%d,Mod13=%d,Range='%f',Health='%f',Owner='%s',Type=%d,RentPrice=%d,Price=%d,Fuel=%d,Faction=%d,Job=%d,Buyable=%d,Locked=%d,Rentable=%d, ParkX='%f',ParkY='%f',ParkZ='%f',ParkAngle='%f',fCarID=%d WHERE vehicleid = %d",
    CarData[vehicleid][vModel],CarData[vehicleid][VPos][0],CarData[vehicleid][VPos][1],CarData[vehicleid][VPos][2],CarData[vehicleid][VPos][3],
    CarData[vehicleid][vColors][0],CarData[vehicleid][vColors][1],CarData[vehicleid][Vmod][0],CarData[vehicleid][Vmod][1],CarData[vehicleid][Vmod][2],CarData[vehicleid][Vmod][3],
    CarData[vehicleid][Vmod][4],CarData[vehicleid][Vmod][5],CarData[vehicleid][Vmod][6],CarData[vehicleid][Vmod][7],CarData[vehicleid][Vmod][8],
    CarData[vehicleid][Vmod][9],CarData[vehicleid][Vmod][10],CarData[vehicleid][Vmod][11],CarData[vehicleid][Vmod][12], CarData[vehicleid][Range],
    CarData[vehicleid][vHealth],CarData[vehicleid][Owner],CarData[vehicleid][Type],CarData[vehicleid][RentPrice],CarData[vehicleid][Price],
    GetVehicleFuel(vehicleid),CarData[vehicleid][Faction],CarData[vehicleid][Job],CarData[vehicleid][Buyable],CarData[vehicleid][Locked],
    CarData[vehicleid][Rentable],CarData[vehicleid][ParkPos][0],CarData[vehicleid][ParkPos][1],CarData[vehicleid][ParkPos][2],CarData[vehicleid][ParkPos][3],CarData[vehicleid][FCarID], vehicleid);
    mysql_query(string);
}
Reply
#2

Maybe the line is to long. Did you try splitting it into 2 queries?
Reply
#3

Quote:
Originally Posted by FUNExtreme
Maybe the line is to long. Did you try splitting it into 2 queries?
If the line was too long, PAWNO would of told me, and also.. I've written longer querys before..
Reply
#4

Did you check if everything is correct in the mysql table. For example that Range isn't range in your table (Note the r not being capitalized)
Reply
#5

Quote:
Originally Posted by FUNExtreme
Did you check if everything is correct in the mysql table. For example that Range isn't range in your table (Note the r not being capitalized)
I'm positive..

[code=MySQL]
DROP TABLE IF EXISTS `Vehicles`;
CREATE TABLE `Vehicles` (
`vehicleid` int(20) NOT NULL AUTO_INCREMENT,
`Model` int(11) NOT NULL,
`X` float NOT NULL,
`Y` float NOT NULL,
`Z` float NOT NULL,
`Angle` float NOT NULL,
`Color1` int(11) NOT NULL,
`Color2` int(11) NOT NULL,
`Mod1` int(11) NOT NULL,
`Mod2` int(11) NOT NULL,
`Mod3` int(11) NOT NULL,
`Mod4` int(11) NOT NULL,
`Mod5` int(11) NOT NULL,
`Mod6` int(11) NOT NULL,
`Mod7` int(11) NOT NULL,
`Mod8` int(11) NOT NULL,
`Mod9` int(11) NOT NULL,
`Mod10` int(11) NOT NULL,
`Mod11` int(11) NOT NULL,
`Mod12` int(11) NOT NULL,
`Mod13` int(11) NOT NULL,
`Range` float NOT NULL,
`Health` float NOT NULL,
`Owner` text NOT NULL,
`Type` int(11) NOT NULL,
`RentPrice` int(11) NOT NULL,
`Price` int(11) NOT NULL,
`Fuel` int(11) NOT NULL,
`Faction` int(11) NOT NULL,
`Job` int(11) NOT NULL,
`Buyable` int(11) NOT NULL,
`Locked` int(11) NOT NULL,
`Rentable` int(11) NOT NULL,
`ParkX` float NOT NULL,
`ParkY` float NOT NULL,
`ParkZ` float NOT NULL,
`ParkAngle` float NOT NULL,
`fCarID` int(11) NOT NULL,
PRIMARY KEY (`vehicleid`),
KEY `vehicleid` (`vehicleid`)
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;[/code]
Reply
#6

I can't see it either, sorry
Reply
#7

Quote:
Originally Posted by FUNExtreme
I can't see it either, sorry

* Carlton throws a suger cookie at FUNExtreme *


You did what you can do, I like that. Thanks for trying.
Reply
#8

I fixed the problem in my tests by changing Range = '0.0000000' TO `Range` = '0.000000'. It may be a reserved word, a statement, im not really sure; Either way its best to surround columns and tables with ``.
Reply
#9

Quote:
Originally Posted by Kyosaur!!
I fixed the problem in my tests by changing Range = '0.0000000' TO `Range` = '0.000000'. It may be a reserved word, a statement, im not really sure; Either way its best to surround columns and tables with ``.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)