Saving Vehicle(SQL R39) -
Lynn - 18.01.2015
What am I doing wrong here?
The vehicles spawn, however they do not save to the 'vehicles' Database.
pawn Код:
CMD:createveh(playerid,params[]){
new query[128], vehid;
mysql_format(db_connect,query,sizeof(query),"SELECT vID FROM vehicles");
new Cache:result = mysql_query(db_connect,query);
for(new i = 0; i < cache_get_row_count(); i++){
vehcount = cache_get_field_content_int(i,"vID");
}
cache_delete(result);
if(sscanf(params,"i",vehid))return SendClientMessage(playerid,-1,"Usage: {FF0000}/createveh [vehicleid]");
vehcount++;
D_Info[vehcount][v_Model] = vehid;
GetPlayerFacingAngle(playerid, D_Info[vehcount][v_A]);
GetPlayerPos(playerid,D_Info[vehcount][v_X],D_Info[vehcount][v_Y],D_Info[vehcount][v_Z]);
CreateVehicle(D_Info[vehcount][v_Model], D_Info[vehcount][v_X],D_Info[vehcount][v_Y],D_Info[vehcount][v_Z], D_Info[vehcount][v_A], -1, -1, 60000);
mysql_format(db_connect,query,sizeof(query), "INSERT INTO `vehicles` (`Owned`, `Locked`, `Forsale`, `Team`, `Color`,\
`Color2`, `X`, `Y`, `Z`, `FAngle`, `Price`, `Model`) VALUES (0,0,0,0,0,0,0,0,0,0,0,0)");
mysql_tquery(db_connect, query, "", "");
return 1;
}
SQL Log
Код:
[12:23:57] [DEBUG] mysql_format - connection: 0, len: 128, format: "SELECT vID FROM vehicles"
[12:23:57] [ERROR] "mysql_format" - invalid connection handle (id: 0)
[12:23:57] [DEBUG] mysql_query - connection: 0, query: "", use_cache: true
[12:23:57] [ERROR] "mysql_query" - invalid connection handle (id: 0)
[12:23:57] [DEBUG] cache_get_row_count - connection: 1
[12:23:57] [WARNING] cache_get_row_count - no active cache
[12:23:57] [DEBUG] cache_delete - cache_id: 0, connection: 1
[12:23:57] [WARNING] CMySQLHandle::DeleteSavedResult - invalid result id ('0')
[12:24:00] [DEBUG] mysql_format - connection: 0, len: 128, format: "SELECT vID FROM vehicles"
[12:24:00] [ERROR] "mysql_format" - invalid connection handle (id: 0)
[12:24:00] [DEBUG] mysql_query - connection: 0, query: "", use_cache: true
[12:24:00] [ERROR] "mysql_query" - invalid connection handle (id: 0)
[12:24:00] [DEBUG] cache_get_row_count - connection: 1
[12:24:00] [WARNING] cache_get_row_count - no active cache
[12:24:00] [DEBUG] cache_delete - cache_id: 0, connection: 1
[12:24:00] [WARNING] CMySQLHandle::DeleteSavedResult - invalid result id ('0')
[12:24:00] [DEBUG] mysql_format - connection: 0, len: 128, format: "INSERT INTO `vehicles` (`Owned`, `Locked`, `Forsale`, `Team`, `Color`,`Color2`, `X`, `Y`, `Z`, `FAngle`, `Price`, `Model`) VALUE..."
[12:24:00] [ERROR] "mysql_format" - invalid connection handle (id: 0)
[12:24:00] [DEBUG] mysql_tquery - connection: 0, query: "", callback: "(null)", format: "(null)"
[12:24:00] [ERROR] "mysql_tquery" - invalid connection handle (id: 0)
[12:24:04] [DEBUG] mysql_format - connection: 0, len: 128, format: "SELECT vID FROM vehicles"
[12:24:04] [ERROR] "mysql_format" - invalid connection handle (id: 0)
[12:24:05] [DEBUG] mysql_query - connection: 0, query: "", use_cache: true
[12:24:05] [ERROR] "mysql_query" - invalid connection handle (id: 0)
[12:24:05] [DEBUG] cache_get_row_count - connection: 1
[12:24:05] [WARNING] cache_get_row_count - no active cache
[12:24:05] [DEBUG] cache_delete - cache_id: 0, connection: 1
[12:24:05] [WARNING] CMySQLHandle::DeleteSavedResult - invalid result id ('0')
[12:24:05] [DEBUG] mysql_format - connection: 0, len: 128, format: "INSERT INTO `vehicles` (`Owned`, `Locked`, `Forsale`, `Team`, `Color`,`Color2`, `X`, `Y`, `Z`, `FAngle`, `Price`, `Model`) VALUE..."
[12:24:05] [ERROR] "mysql_format" - invalid connection handle (id: 0)
[12:24:05] [DEBUG] mysql_tquery - connection: 0, query: "", callback: "(null)", format: "(null)"
[12:24:05] [ERROR] "mysql_tquery" - invalid connection handle (id: 0)
Re: Saving Vehicle(SQL R39) -
Ironboy - 18.01.2015
It'd be good if you post the mysql_log along with the command.
Re: Saving Vehicle(SQL R39) -
Lynn - 18.01.2015
Updated.
Re: Saving Vehicle(SQL R39) -
Vince - 18.01.2015
What the hell do you expect if you don't insert any actual variables?
Re: Saving Vehicle(SQL R39) -
PowerPC603 - 18.01.2015
Did you connect to the database in the first place during OnGameModeInit?
Your database connection handle (db_connect) holds 0 instead of 1 and is invalid.
Re: Saving Vehicle(SQL R39) -
Lynn - 18.01.2015
Can you provide example code please..I'm trying to learn.
Yes it connects to the DB.