(error #1054) Unknown column '0' in 'field list' -
Jack_Leslie - 15.09.2014
I know what the error means, but I don't have a '0' column, and I do have every column made in the table, and it is the right table, here's the query below:
Code:
mysql_format(propertiesLine, query, sizeof(query), "INSERT INTO `houses` (`cID`, `Address`, `hX`, `hY`, `hZ`, `hA`, `Level`, `Value`, `SalePrice`, `ForSale`) VALUES (`%d`, `%s`, `%f`, `%f`, `%f`, `%f`, `%d`, `%d`, `%d`, `%d`)",\
cache_insert_id(), zone, HouseData[id][hX], HouseData[id][hY], HouseData[id][hZ], HouseData[id][hA], HouseData[id][Level], HouseData[id][Value], HouseData[id][Value], 1);
Re: (error #1054) Unknown column '0' in 'field list' -
Eth - 15.09.2014
are you sure it's the right line? because from what I see, there is nothing wrong with it at all
EDIT: maybe you need to use a function like mysql_tquery to insert the query to the database?
Re: (error #1054) Unknown column '0' in 'field list' -
Jack_Leslie - 15.09.2014
Here's the mysql log:
Code:
[16:10:17] [DEBUG] mysql_format - connection: 9, len: 2056, format: "INSERT INTO `houses` (`cID`, `Address`, `hX`, `hY`, `hZ`, `hA`, `Level`, `Value`, `SalePrice`, `ForSale`) VALUES (`%d`, `%s`, `%..."
[16:10:17] [DEBUG] mysql_tquery - connection: 9, query: "INSERT INTO `houses` (`cID`, `Address`, `hX`, `hY`, `hZ`, `hA`, ", callback: "(null)", format: "(null)"
[16:10:17] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[16:10:17] [ERROR] CMySQLQuery::Execute[] - (error #1054) Unknown column '0' in 'field list'
[16:10:17] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError
[16:10:17] [DEBUG] Calling callback "OnQueryError"..
Re: (error #1054) Unknown column '0' in 'field list' -
Eth - 15.09.2014
show me the enums pls
Re: (error #1054) Unknown column '0' in 'field list' -
Jack_Leslie - 15.09.2014
pawn Code:
enum data_Houses {
cID,
Created,
Address[129],
Owner[MAX_PLAYER_NAME],
Owned,
Locked,
Float:hX,
Float:hY,
Float:hZ,
Float:hA,
Level,
Value,
ForSale,
SalePrice,
Rent,
RentPrice,
Float:signX,
Float:signY,
Float:signZ,
Float:signA,
signObj
};
new HouseData[MAX_HOUSES][data_Houses];
Re: (error #1054) Unknown column '0' in 'field list' -
SilentSoul - 15.09.2014
Use
'%s' if you're going to insert a string in your database, this happens to me before the reason was the same as yours, you shouldn't use `%s` to insert strings.
pawn Code:
mysql_format(propertiesLine, query, sizeof(query), "INSERT INTO `houses` (`cID`, `Address`, `hX`, `hY`, `hZ`, `hA`, `Level`, `Value`, `SalePrice`, `ForSale`) VALUES (`%d`, '%s', `%f`, `%f`, `%f`, `%f`, `%d`, `%d`, `%d`, `%d`)",\
cache_insert_id(), zone, HouseData[id][hX], HouseData[id][hY], HouseData[id][hZ], HouseData[id][hA], HouseData[id][Level], HouseData[id][Value], HouseData[id][Value], 1);
Re: (error #1054) Unknown column '0' in 'field list' -
Eth - 15.09.2014
not only the strings, but all of them too!
pawn Code:
mysql_format(propertiesLine, query, sizeof(query), "INSERT INTO `houses` (`cID`, `Address`, `hX`, `hY`, `hZ`, `hA`, `Level`, `Value`, `SalePrice`, `ForSale`) VALUES ('%d', '%s', '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%d')",\
cache_insert_id(), zone, HouseData[id][hX], HouseData[id][hY], HouseData[id][hZ], HouseData[id][hA], HouseData[id][Level], HouseData[id][Value], HouseData[id][Value], 1);
Re: (error #1054) Unknown column '0' in 'field list' -
Vince - 15.09.2014
Quote:
Originally Posted by Eth
not only the strings, but all of them too!
|
No, just the strings. Putting other values in quotes forces MySQL to do an implicite conversion from string to it's proper type. Also get rid of the backticks altogether. They're just a nuisance. If you need to use them, you might consider renaming your fields.
Re: (error #1054) Unknown column '0' in 'field list' -
Jack_Leslie - 16.09.2014
Great, thanks guys.