SA-MP Forums Archive
Insert vehicle into DB ? - 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)
+--- Thread: Insert vehicle into DB ? (/showthread.php?tid=643429)



Insert vehicle into DB ? - Klayton - 20.10.2017

Hello, can you help me with my script, the vehicle is not insert into my DB after a cmd /veh


check the code: https://pastebin.com/xmiZxbRp


Re: Insert vehicle into DB ? - Zeth - 20.10.2017

PHP Code:
mysql_format(dbhandlequerysizeof(query), "INSERT INTO `server_vehicles` SET Model='%d',Color1='%d',Color2='%d',PosX='%d',PosY='%d',PosZ='%d',PosA='%d'"
Here the format specifier is wrong, here posx, y, z and a have been declared as Float, therefore you need to follow the correct format.
here is the corrected line.
PHP Code:
mysql_format(dbhandlequerysizeof(query), "INSERT INTO `server_vehicles` SET Model='%d',Color1='%d',Color2='%d',PosX='%f',PosY='%f',PosZ='%f',PosA='%f'"



Re: Insert vehicle into DB ? - Klayton - 20.10.2017

Oh yeah exactly for %f , thank's, but , I have again the problem of insert


Re: Insert vehicle into DB ? - Zeth - 20.10.2017

Ah Sorry , didnt noticed that, you are using a wrong INSERT syntax read more here
Here is the corrected line
PHP Code:
mysql_format(dbhandlequerysizeof(query), "INSERT INTO `server_vehicles` (Model, Color1, Color2, PosX, PosY, PosZ, PosA)VALUES('%d', '%d', '%d', '%f', '%f', '%f', '%f')"Vehicle_infos[vehicleid][v_Model], Vehicle_infos[vehicleid][v_Color1], Vehicle_infos[vehicleid][v_Color2], Vehicle_infos[vehicleid][v_PosX], Vehicle_infos[vehicleid][v_PosY], Vehicle_infos[vehicleid][v_PosZ], Vehicle_infos[vehicleid][v_PosA]); 



Re: Insert vehicle into DB ? - Klayton - 20.10.2017

Ok bro ! But my syntax its ok with this cmd !

/pickup [ITS OKAY] > https://pastebin.com/1vkUgJam
/veh2 [WRONG] > https://pastebin.com/rD5s3vF3

Its correctly insert into db , and not with /veh, why ?


Re: Insert vehicle into DB ? - justice96 - 20.10.2017



Do what Debjit said above, he clearly explains you about the query.

Quote:
Originally Posted by Debjit
View Post
Ah Sorry , didnt noticed that, you are using a wrong INSERT syntax read more here
Here is the corrected line
PHP Code:
mysql_format(dbhandlequerysizeof(query), "INSERT INTO `server_vehicles` (Model, Color1, Color2, PosX, PosY, PosZ, PosA)VALUES('%d', '%d', '%d', '%f', '%f', '%f', '%f')"Vehicle_infos[vehicleid][v_Model], Vehicle_infos[vehicleid][v_Color1], Vehicle_infos[vehicleid][v_Color2], Vehicle_infos[vehicleid][v_PosX], Vehicle_infos[vehicleid][v_PosY], Vehicle_infos[vehicleid][v_PosZ], Vehicle_infos[vehicleid][v_PosA]); 



Re: Insert vehicle into DB ? - Klayton - 20.10.2017

Yeah but with this syntax, its again wrong


Re: Insert vehicle into DB ? - justice96 - 20.10.2017

what's wrong with those syntax? do you get any errors?


Re: Insert vehicle into DB ? - Klayton - 20.10.2017

No, no errors, just the line is not insert into DB


Re: Insert vehicle into DB ? - Zeth - 20.10.2017

Check MySQL Logs.its there in log folder.
Make sure you got mysql_log(ERROR | WARNING); or mysql_log(ALL); under OnGameModeInit.

I think you got some problems in your SendQuery Function, Can you show SendQuery Function.
or Maybe your callback parameters are not same as of the function.


Re: Insert vehicle into DB ? - Klayton - 20.10.2017

Ok i'm stupid lol, its okay bro !

But, the float position is not save , look

> http://prntscr.com/gzozhg


Re: Insert vehicle into DB ? - Zeth - 20.10.2017

Check your MySQL structure if they are assigned as float or not


Re: Insert vehicle into DB ? - Klayton - 20.10.2017

Yeah is float