04.08.2013, 18:34
Hello,
I've made a function which adds a row to my sql database containing the vehicle's information. I refer to this row again with an ID, which I auto-increment (AI). So for example, if it loads 3 vehicles I'll be able to refer back to any of them with the ID in the database, which I saved into the vehicleinfo enum when I load the vehicles.
I have created a function so I can save new vehicles into the database from in-game and I'll have to retrieve the AI-integer it gave the row, to save it into the vehicleinfo enum. You can easily do this with the mysql_insert_id. The thing is that either the query's too slow or the mysql_insert_id too fast, so I'm not able to retrieve it properly.
Assuming I have 3 vehicles and I'm saving the 4th. Currently, the first time I do it it'll give me a 0 (which means it's no result), whereas it's supposed to give 4. If I then add another vehicle, the 5th one, it'll give me the 'old' result, 4, instead of the 5 it's supposed to show me. I have checked, if I run it with a timer function of 6 milliseconds, it'll work properly. The problem is that it's just unpractical and I was wondering if you guys knew either a solution or a workaround.
If you have any further questions, feel free to ask! Thanks in advance
I've made a function which adds a row to my sql database containing the vehicle's information. I refer to this row again with an ID, which I auto-increment (AI). So for example, if it loads 3 vehicles I'll be able to refer back to any of them with the ID in the database, which I saved into the vehicleinfo enum when I load the vehicles.
I have created a function so I can save new vehicles into the database from in-game and I'll have to retrieve the AI-integer it gave the row, to save it into the vehicleinfo enum. You can easily do this with the mysql_insert_id. The thing is that either the query's too slow or the mysql_insert_id too fast, so I'm not able to retrieve it properly.
Assuming I have 3 vehicles and I'm saving the 4th. Currently, the first time I do it it'll give me a 0 (which means it's no result), whereas it's supposed to give 4. If I then add another vehicle, the 5th one, it'll give me the 'old' result, 4, instead of the 5 it's supposed to show me. I have checked, if I run it with a timer function of 6 milliseconds, it'll work properly. The problem is that it's just unpractical and I was wondering if you guys knew either a solution or a workaround.
If you have any further questions, feel free to ask! Thanks in advance