SA-MP Forums Archive
Duplicate error - 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: Duplicate error (/showthread.php?tid=614654)



Duplicate error - Edevane - 10.08.2016

So the problem is, the first vehicle is can be created but if i try to create the second vehicle, its no longer wants to create the vehicle in the database, only in game

Quote:

OnQueryError:
error: "Duplicate entry '1' for key 'PRIMARY'"
query: "INSERT INTO `Jarmuvek` (`ID`, `Tulajdonos`, `Tipus`, `Szin1`, `Szin2`, `Elado` ,`Ar`, `Elet`, `Uzemanyag`, `Panelek`, `Lampak` , `Ajtok` , `Kerekek` , `Hidraulika`, `Matrica` , `Frakcio` , `Zar` , `PosX` , `PosY` , `PosZ` , `PosA`) VALUES ('1', 0, '411', '1', '1', '1' , '0', 1000, 0, 0 , 0 , 0 , 0, 0 , 0 , 0 , 0 , -1614.268, 1228.275, 7.047, 283.651)"




Re: Duplicate error - ThePhenix - 10.08.2016

That's because, as we can assume looking at your code the field "ID" is a primary key, thus there can only be one row with ID 1. Hence, the field "ID" should be an auto increment column where all you need to do is insert the data and retrieve the ID inserted using cache_insert_id();

PHP код:
INSERT INTO `Jarmuvek` (`Tulajdonos`, `Tipus`, `Szin1`, `Szin2`, `Elado` ,`Ar`, `Elet`, `Uzemanyag`, `Panelek`, `Lampak` , `Ajtok` , `Kerekek` , `Hidraulika`, `Matrica` , `Frakcio` , `Zar` , `PosX` , `PosY` , `PosZ` , `PosA`) VALUES (0'411''1''1''1' '0'100000, -1614.2681228.2757.047283.651)



Re: Duplicate error - Konstantinos - 10.08.2016

That's because ID has been set as primary key with auto increment. Remove `ID` from columns and '1' from the values and it will generate the value itself.


Re: Duplicate error - Edevane - 10.08.2016

Thanks, this forum is very good.