Mzor Posted March 3, 2009 Share Posted March 3, 2009 I'm sorry if there is already a thread asking this question, I searched but wasn't really sure of what keywords to use. Anyway, this is my question. What I need to do is somehow retrieve an automatically incremented primary key from a row that I just inserted. So something like, if a user just posted a comment, the PHP script could tell them that, "Your comment's ID is $comment_id" (Made up situation). Thanks for the help. I know there are ways to get that variale, ut those other ways just require more scripting and more queries. Quote Link to comment https://forums.phpfreaks.com/topic/147794-solved-retrieving-an-inserted-value-on-an-insert-command/ Share on other sites More sharing options...
Maq Posted March 3, 2009 Share Posted March 3, 2009 Look at: mysql_insert_id() Quote Link to comment https://forums.phpfreaks.com/topic/147794-solved-retrieving-an-inserted-value-on-an-insert-command/#findComment-775777 Share on other sites More sharing options...
Mzor Posted March 3, 2009 Author Share Posted March 3, 2009 Aha, thanks a ton. This is exactly what I was looking for. Quote Link to comment https://forums.phpfreaks.com/topic/147794-solved-retrieving-an-inserted-value-on-an-insert-command/#findComment-775779 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.