Duplicate error
#1

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

Reply
#2

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)
Reply
#3

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.
Reply
#4

Thanks, this forum is very good.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)