Jump to content

function to get ID?


EchoFool

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.