View Full Version : SQLite problem

08/06/2012, 02:54 PM
Well for the last 2 hours it seems i've been hitting my head against a brick wall. I just can't seem to get the table to store the data.
I check the values with printf(...) #DEBUGGING# and they show up correct. After everything is supposibly loaded into the Database, I check the Database using a SQLite Browser.
The first table I created stores the data fine, but when it comes to the table I'm trying to store the data in. It just shows the columns with nothing entered.

Here is the SQLite code, I just can't workout where it's going wrong...(Gonna be annoying if its something simple :|)

format(Query, sizeof(Query), "INSERT INTO `%d` (`itemid`,`entityid`,`modelid`,`x`,`y`,`z`,`rx`,`r y`,`rz`,`angle`,`colour1`,`colour2`) VALUES('Object','%d','%d','%f','%f','%f','%f','%f' ,'%f','0','0','0')",id,count,modelid,x,y,z,rx,ry,rz);
Result = db_query(MapDatabase, Query);

Hopefully what I'm asking made sense to you all.

08/06/2012, 03:24 PM
Uh? Are you creating a whole TABLE for each object?

08/06/2012, 03:27 PM
No, I don't think I should be, id is a number that runs throughout the whole script. Everything works until I reach this part. %d id is just the same number basically.

08/06/2012, 03:32 PM
Can you print the 'Query' to server log (after format) and show the result?

Also, would be good if you show your table structure.

08/06/2012, 04:04 PM
[03:53:11] INSERT INTO `4` VALUES('Object','39','2060','-1423.232177','503.596618','17.961086','0.000000',' 0.000000','279.965087','0','0','0')
[03:53:11] Object 175 saved into database
[03:53:11] ModelID 2060, InteriorID 0, WorldID 0, PosX -1423.535156, PosY 504.627136, PosZ 17.986085, PosRX 0.000000, PosRY 0.000000, PosRZ 289.964599
[03:53:11] Object 177 loaded into slot 39
[03:53:11] INSERT INTO `4` VALUES('Object','40','2060','-1423.535156','504.627136','17.986085','0.000000',' 0.000000','289.964599','0','0','0')
[03:53:11] Object 177 saved into database

Here are 2 values, the INSERT INTO is the query. The ModelID = "" is the printf to debug this

08/06/2012, 04:27 PM
Discovered the problem, apparently SQLite doesn't like when it has a number for tables. Idk if this is correct but its working now for me :D

Thank you everyone that assisted me in this!