EchoFool Posted April 12, 2008 Share Posted April 12, 2008 Does any one know if there is such a function to get the ID of the row that was inserted into the database from the query before? Like: //inserted query //get id of the row that was just inserted Been searching cannot find it, but it must surely be a real function some how or must be do-able in some way? Link to comment https://forums.phpfreaks.com/topic/100843-function-to-get-id/ Share on other sites More sharing options...
poleposters Posted April 12, 2008 Share Posted April 12, 2008 mysql_insert_id You're probably doing something similar to this. $query = "INSERT INTO users (business_id, email, pass,business, business_type, first_name, last_name, active,paid_listing, registration_date) VALUES ('','$e', SHA('$p'),'$bn', '$cat','$fn', '$ln', '$a',0, NOW() )"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); $bid=mysql_insert_id(); $query2 = "INSERT INTO address (address_id,business_id,unit_number,street_number, address, postcode) VALUES ('','$bid','$bn','$un','$sn' '$ad','$pc')"; $result2 = mysql_query ($query2) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); Link to comment https://forums.phpfreaks.com/topic/100843-function-to-get-id/#findComment-515679 Share on other sites More sharing options...
EchoFool Posted April 12, 2008 Author Share Posted April 12, 2008 nice one ! Yeahs that pretty much is what im trying to do trying to log down the ID of the effected row so staff can check it out. Thanks Link to comment https://forums.phpfreaks.com/topic/100843-function-to-get-id/#findComment-515680 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.