16.11.2010, 19:00
Ok well it would appear that using your system, you need to execute the query string then at the very end, which you have not done, therefore it's not saving.
Also there's no need for
mysql_store_result();
mysql_free_result();
As you're not selecting any information from the database in that entire snippet of code.
Additionally it appears you create a string in the local scope and it is never used.
The end result is this:
Note to Grim_: Actually he is not executing a query each time, I thought that at first also which is indeed quite silly, but that is not what he is doing, those functions actually build a large query string, which should then be executed, which is what he forgot to do.
Also of course Grim_ is correct, you really should have a connection open when the server is started, each time a function is called.
Also there's no need for
mysql_store_result();
mysql_free_result();
As you're not selecting any information from the database in that entire snippet of code.
Additionally it appears you create a string in the local scope and it is never used.
The end result is this:
pawn Код:
public SaveCar() // mySQL
{
MySQLConnect(MYSQL_HOST,MYSQL_USER,MYSQL_PASS,MYSQL_DB);
for(new idx = 115; idx < CARINFOMAX; idx++)
{
MySQLCheckConnection();
new query[MAX_STRING];
format(query, MAX_STRING, "UPDATE cars SET ");
MySQLUpdatePlayerStr2(query, idx, "Model", CarInfo[idx][cModel]);
MySQLUpdatePlayerFlo2(query, idx, "Locationx", CarInfo[idx][cLocationx]);
MySQLUpdatePlayerFlo2(query, idx, "Locationy", CarInfo[idx][cLocationy]);
MySQLUpdatePlayerFlo2(query, idx, "Locationz", CarInfo[idx][cLocationz]);
MySQLUpdatePlayerFlo2(query, idx, "Angle", CarInfo[idx][cAngle]);
MySQLUpdatePlayerStr2(query, idx, "ColorOne", CarInfo[idx][cColorOne]);
MySQLUpdatePlayerStr2(query, idx, "ColorTwo", CarInfo[idx][cColorTwo]);
//----------------------------------------------------------------------
MySQLUpdatePlayerStr2(query, idx, "Owner", CarInfo[idx][cOwner]);
MySQLUpdatePlayerStr2(query, idx, "Description", CarInfo[idx][cDescription]);
//----------------------------------------------------------------------
MySQLUpdatePlayerStr2(query, idx, "Value", CarInfo[idx][cValue]);
MySQLUpdatePlayerStr2(query, idx, "License", CarInfo[idx][cLicense]);
MySQLUpdatePlayerStr2(query, idx, "Owned", CarInfo[idx][cOwned]);
//----------------------------------------------------------------------
MySQLUpdatePlayerStr2(query, idx, "Paintjob", CarInfo[idx][cPaintjob]);
MySQLUpdatePlayerStr2(query, idx, "mod1", CarInfo[idx][cmod1]);
MySQLUpdatePlayerStr2(query, idx, "mod2", CarInfo[idx][cmod2]);
MySQLUpdatePlayerStr2(query, idx, "mod3", CarInfo[idx][cmod3]);
MySQLUpdatePlayerStr2(query, idx, "mod4", CarInfo[idx][cmod4]);
MySQLUpdatePlayerStr2(query, idx, "mod5", CarInfo[idx][cmod5]);
MySQLUpdatePlayerStr2(query, idx, "mod6", CarInfo[idx][cmod6]);
MySQLUpdatePlayerStr2(query, idx, "mod7", CarInfo[idx][cmod7]);
MySQLUpdatePlayerStr2(query, idx, "mod8", CarInfo[idx][cmod8]);
MySQLUpdatePlayerStr2(query, idx, "mod9", CarInfo[idx][cmod9]);
MySQLUpdatePlayerStr2(query, idx, "mod10", CarInfo[idx][cmod10]);
MySQLUpdatePlayerStr2(query, idx, "mod11", CarInfo[idx][cmod11]);
MySQLUpdatePlayerStr2(query, idx, "mod12", CarInfo[idx][cmod12]);
MySQLUpdatePlayerStr2(query, idx, "mod13", CarInfo[idx][cmod13]);
MySQLUpdatePlayerStr2(query, idx, "mod14", CarInfo[idx][cmod14]);
MySQLUpdatePlayerStr2(query, idx, "mod15", CarInfo[idx][cmod15]);
MySQLUpdatePlayerStr2(query, idx, "mod16", CarInfo[idx][cmod16]);
MySQLUpdatePlayerStr2(query, idx, "mod17", CarInfo[idx][cmod17]);
//----------------------------------------------------------------------
mysql_query(query);
}
}
Also of course Grim_ is correct, you really should have a connection open when the server is started, each time a function is called.