SA-MP Forums Archive
MYSQL - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MYSQL (/showthread.php?tid=265762)



MYSQL - Stefans94 - 02.07.2011

Код:
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


Re: MYSQL - breakpaper - 02.07.2011

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


Re: MYSQL - Stefans94 - 02.07.2011

Код:
[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


Re: MYSQL - [HiC]TheKiller - 02.07.2011

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);



Re: MYSQL - Stefans94 - 02.07.2011

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