Car Colors command and MySQL -
GuitarMan - 21.01.2015
Hey!
I was trying to make a car color changing command. It does change the color, but it wont save the color values in database". So here is the code:
PHP код:
CMD:vcolor(playerid, params[])
{
if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, 0xFF0000FF, "You are not driving a vehicle.");
new color[2];
if(sscanf(params, "iI(-1)", color[0], color[1]))
{
return SendClientMessage(playerid, 0xFF0000FF, "Piemers: /vcolor [krasa1] [krasa2]");
}
if(color[1] == -1) color[1] = color[0]; // If color2 was left out, set it the same as color 1
new szSuccess[44];
format(szSuccess, sizeof(szSuccess), "Vehicle colors changed to: {FFFFFF}%i and %i.", color[0], color[1]);
SendClientMessage(playerid, 0x00FF00FF, szSuccess);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color[0], color[1]);
new Query[128];
format(query,sizeof(query),"UPDATE `TABLE_CARS` SET `colors` = '%i, %i' WHERE `id` = '%i'", color[0], color[1], 1);
return mysql_query(Query);
return 1;
}
Heres how my database looks:
http://prntscr.com/5vd34k
And heres the table Cars settings:
http://prntscr.com/5vd3kf
Also, this is how the Table_Cars define looks:
PHP код:
#define TABLE_ACCOUNT "accounts"
#define TABLE_HOUSE "house"
#define TABLE_BIZZ "bizz"
#define TABLE_CARS "cars"
#define TABLE_FRACTION "fraction"
#define TABLE_ENTERS "enters"
#define TABLE_PICK "mayor"
#define TABLE_OTHER "other"
#define TABLE_GPS "gps"
#define TABLE_VEH "vehicle"
#define TABLE_ATM "atm"
#define TABLE_GANGZONE "gangzone"
#define TABLE_MAFIA "mafia"
If theres more information necessary please let me know.
Re: Car Colors command and MySQL -
Ironboy - 21.01.2015
You'd better show the mysql log.
Re: Car Colors command and MySQL -
GuitarMan - 21.01.2015
PHP код:
[01:01:56] CMySQLHandler::Query() - An error has occured. (Error ID: 1065, Query was empty)
[01:02:23] >> mysql_query( Connection handle: 1 )
[01:02:23] CMySQLHandler::Query() - An error has occured. (Error ID: 1065, Query was empty)
[01:02:25] >> mysql_query( Connection handle: 1 )
[01:02:25] CMySQLHandler::Query() - An error has occured. (Error ID: 1065, Query was empty)
Here it is.
Just after i used the command, it says that the Query was empty. But how could it be empty? =o
Re: Car Colors command and MySQL -
nGen.SoNNy - 21.01.2015
pawn Код:
new Query[128];
format(Query,sizeof(Query),"UPDATE `TABLE_CARS` SET `colors` = '%i, %i' WHERE `id` = 1", color[0], color[1] );
change these lines
Re: Car Colors command and MySQL -
Schneider - 21.01.2015
Watch the capitals,
you're formatting 'query' (with lower-case q and use 'Query' (with capital Q) in the mysql-function.
Re: Car Colors command and MySQL -
Ironboy - 21.01.2015
When you're using a define for the table use it inside the quotation mark as shown below
pawn Код:
format(query,sizeof(query),"UPDATE `"TABLE_CARS"` SET `colors` = '%i, %i' WHERE `id` = '%i'", color[0], color[1], 1);
Re: Car Colors command and MySQL -
GuitarMan - 21.01.2015
Thanks! It worked!