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. 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() 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. 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
Archived
This topic is now archived and is closed to further replies.