#1

Код:
if (strcmp("/createveh", cmdtext, true, 10) == 0)
	{
		new Float:x,
		    Float:y,
		    Float:z,
		    Float:angle;
		new veh;
		veh = GetPlayerVehicleID(playerid);
		GetVehiclePos(veh, x, y, z);
		GetVehicleZAngle(veh, angle);
		new Query[200];
		format(Query, sizeof(Query), "INSERT INTO `vehicles` (`ID`, `model`, `owner`, `price`, `vehx`, `vehy`, `vehz`, `plate`, `color1`, `color2`, `angle`) VALUES '', '%i', '', '', '%f', '%f', '%f', '', '1', '1', '%f'", veh, x, y, z, angle);
		mysql_query(Query);
		return 1;
	}
whats wrong with that? because it doesn't insert in the db
Reply
#2

Go to your OnGameModeInit/OnFilterScriptInit and add this:
Код:
mysql_debug(1);
Start the server. Try it, go to your mysql_log.txt, open that, and check the error
Reply
#3

Код:
[12:44:24]  

[12:44:24] ---------------------------

[12:44:24] MySQL Debugging activated (07/02/11)

[12:44:24] ---------------------------

[12:44:24]  

[12:44:24] >> mysql_connect( )

[12:44:24] CMySQLHandler::CMySQLHandler() - constructor called.

[12:44:24] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "sampdb" | Username: "root" ...

[12:44:24] CMySQLHandler::Connect() - Connection was successful.

[12:44:24] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.

[12:45:18] >> mysql_query( Connection handle: 1 )

[12:45:18] CMySQLHandler::Query(INSERT INTO `vehicles` (`ID`, `model`, `owner`, `price`, `vehx`, `vehy`, `vehz`, `plate`, `color1`, `color2`, `angle`) VALUES '', '1', '', '', '2037.928710', '1319.118530', '10.424090', '', '1', '1',) - An error has occured. (Error ID: 1064, 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 ''', '1', '', '', '2037.928710', '1319.118530', '10.424090', '', '1', '1',' at line 1)
actually, i still don't know what i'm doing wrong XD
Reply
#4

Values need brackets around them aswell.

pawn Код:
format(Query, sizeof(Query), "INSERT INTO `vehicles` (`ID`, `model`, `owner`, `price`, `vehx`, `vehy`, `vehz`, `plate`, `color1`, `color2`, `angle`) VALUES ('', '%i', '', '', '%f', '%f', '%f', '', '1', '1', '%f')", veh, x, y, z, angle);
Reply
#5

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
Values need brackets around them aswell.

pawn Код:
format(Query, sizeof(Query), "INSERT INTO `vehicles` (`ID`, `model`, `owner`, `price`, `vehx`, `vehy`, `vehz`, `plate`, `color1`, `color2`, `angle`) VALUES ('', '%i', '', '', '%f', '%f', '%f', '', '1', '1', '%f')", veh, x, y, z, angle);
ok, but that still doesn't work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)