Lamez Posted August 9, 2009 Share Posted August 9, 2009 Okay I am doing some finishing touches on this script. It is a review script. Here is how it works: 1.User Types a Review 2.Script sends out a email verification to user 3.After email is verified, Review goes into pending, and sends a email to admin 4.Admin either accepts review, or denies it. 5.Script sends out a email to the user telling them they have been accepted or denied. Telling you guys how this works, might help you help me. In the script, after step 1 it adds a record to the database, but I need to know the id before it is added for the URLs, so I made a function that generates the ID from getting the last entry plus one. Here is that function: <?php function getId(){ $q = mysql_query("SELECT MAX(id) FROM `reviews`"); $f = mysql_fetch_array($q); return $f['0']+1; } ?> Does my systems with the IDs sound stable, or should I go a different route of some sorts? Quote Link to comment https://forums.phpfreaks.com/topic/169496-stability-question/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 9, 2009 Share Posted August 9, 2009 Does my systems with the IDs sound stable Nope. If you have multiple concurrent visitors you cannot guarantee that the number you just got that way will be the next available id at that time you use it. You need to actually insert a row first, then get the id of that row (mysql_insert_id) in order to guarantee that the id is accurate for all concurrent instances of your script. Quote Link to comment https://forums.phpfreaks.com/topic/169496-stability-question/#findComment-894295 Share on other sites More sharing options...
Lamez Posted August 9, 2009 Author Share Posted August 9, 2009 Okay, so you are saying I should add the row, then get the ID from the database? Quote Link to comment https://forums.phpfreaks.com/topic/169496-stability-question/#findComment-894300 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.