MySQL Problem
#1

What's wrong with this code? it compiles well, but in game i got a mysql error

Quote:

Error in mysql_query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Lock=0, Ownable=1 WHERE id=198' at line 1

Код:
forward MySQLUpdateCityCar(playerid);
public MySQLUpdateCityCar(playerid) // by Brown
{
	new query[512];
	new owner[32], description[32], plate[32];
	new vehid = GetPlayerVehicleID(playerid);
	samp_mysql_real_escape_string(CityCarInfo[vehid][cOwner], owner);
	samp_mysql_real_escape_string(CityCarInfo[vehid][cDescription], description);
	samp_mysql_real_escape_string(CityCarInfo[vehid][cPlate], plate);
        new currentveh = GetPlayerVehicleID(playerid);
	format(query, sizeof(query), "UPDATE citycars SET x=%f, y=%f, z=%f, a=%f, color1=%d, color2=%d, fraction=%d, Plate='%s', Owner='%s', Description='%s', Value=%d, Owned=%d, Lock=%d, Ownable=%d WHERE id=%d",
	CityCarInfo[vehid][cXPos],
	CityCarInfo[vehid][cYPos],
	CityCarInfo[vehid][cZPos],
	CityCarInfo[vehid][cAngle],
	CityCarInfo[vehid][cColorOne],
	CityCarInfo[vehid][cColorTwo],
	PlayerInfo[playerid][pLeader],
	plate,
	owner,
	description,
	CityCarInfo[vehid][cValue],
	CityCarInfo[vehid][cOwned],
	CityCarInfo[vehid][cLock],
	CityCarInfo[vehid][cOwnable],
	vehid);
	samp_mysql_query(query);
	return 0;
}
Reply
#2

UP ^
Reply
#3

Use
pawn Код:
print(query);
and post the result.
Reply
#4

There isn't a result, the query is failed, Its a UPDATE query, not SELECT.
I have problems too with the 'UPDATE' query's.
Reply
#5

Quote:
Originally Posted by wouter0100
Посмотреть сообщение
There isn't a result, the query is failed, Its a UPDATE query, not SELECT.
I have problems too with the 'UPDATE' query's.
The result of the print.

Reply
#6

aa, yea right.
Fail
Reply
#7

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
Use
pawn Код:
print(query);
and post the result.
result

Quote:

UPDATE citycars SET x=-2265.620117, y=121.426002, z=34.852798, a=267.880004, color1=0, color2=0, fraction=1, Plate='SA-MP.GE', Owner='George_Petrelli', Description='Vehicle', Lock=0, Value=10000000, Owned=1 WHERE id=197

Reply
#8

pawn Код:
forward MySQLUpdateCityCar(playerid);
public MySQLUpdateCityCar(playerid) // by Brown
{
    new query[512];
    new owner[32], description[32], plate[32];
    new vehid = GetPlayerVehicleID(playerid);
    samp_mysql_real_escape_string(CityCarInfo[vehid][cOwner], owner);
    samp_mysql_real_escape_string(CityCarInfo[vehid][cDescription], description);
    samp_mysql_real_escape_string(CityCarInfo[vehid][cPlate], plate);
        new currentveh = GetPlayerVehicleID(playerid);
    format(query, sizeof(query), "UPDATE `citycars` SET x = '%f', y = '%f', z = '%f', a = '%f', color1 = '%d', color2 = '%d', fraction = '%d', Plate ='%s', Owner='%s', Description='%s', Value = '%d', Owned = '%d' , Lock = '%d', Ownable = '%d' WHERE id = '%d'",
    CityCarInfo[vehid][cXPos],
    CityCarInfo[vehid][cYPos],
    CityCarInfo[vehid][cZPos],
    CityCarInfo[vehid][cAngle],
    CityCarInfo[vehid][cColorOne],
    CityCarInfo[vehid][cColorTwo],
    PlayerInfo[playerid][pLeader],
    plate,
    owner,
    description,
    CityCarInfo[vehid][cValue],
    CityCarInfo[vehid][cOwned],
    CityCarInfo[vehid][cLock],
    CityCarInfo[vehid][cOwnable],
    vehid);
    samp_mysql_query(query);
    return 0;
}
You were forgetting the ' ' between the variables.
Somewhere you had them added, somewhere not.
Reply
#9

the same error again..

Quote:

Error in mysql_query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Lock = '0', Ownable = '1' WHERE id = '199'' at line 1

Reply
#10

Do like that to all:
Код:
`y` = '%f'
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)