rahul.pache Posted June 12, 2008 Share Posted June 12, 2008 I am using php and mysql I want to insert some data in database. Database is id (primary key, auto increment) | email address | password I insert data like $query1 = "insert into DatabaseName values(NULL, 'Tony@tony.com', 'Tony ...... ')"; then execute the query BUT I want to retrieve the ID which has been just set for inserted data. Please suggest me the optimal solution..... (I don't want to search again for the data inserted and get its id.) Is there any direct solution for doing this Plz help I will be thankfull. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted June 12, 2008 Share Posted June 12, 2008 right after the insert command, use mysql_insert_id() Quote Link to comment Share on other sites More sharing options...
rahul.pache Posted June 19, 2008 Author Share Posted June 19, 2008 Thanx dude !!! When I searched on php.net about the function I found this does not work if id is BIGINT for that case we have to use LAST_INSERT_ID() function Thanx alot ... Quote Link to comment 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.