(error #1054) Unknown column '0' in 'field list'
#1

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);
Reply
#2

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?
Reply
#3

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"..
Reply
#4

show me the enums pls
Reply
#5

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];
Reply
#6

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);
Reply
#7

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);
Reply
#8

Quote:
Originally Posted by Eth
View Post
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.
Reply
#9

Great, thanks guys.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)