Jump to content

[SOLVED] Getting The Primary's Auto incremented val right after a new record is inserted


newbreed65

Recommended Posts

As you will see from the code below i have a MYSQL Query which adds a person data to my database, but when it come to the next part were i upload the persons image (if they have added one) I want to use the value from the primary key (person_id) ) that is  Auto incremented as the images name, is there away to just get the ID instead if running another query like you would if you were displaying the data on a page

 

 

   
$sql = "INSERT INTO team
(person_firstname, person_surname, person_role, person_info, person_image)
  VALUES ('" . mysql_real_escape_string($firstname) . "',
              '" . mysql_real_escape_string($surname) . "',
	'" . mysql_real_escape_string($role) . "',
	'" . mysql_real_escape_string($info) . "',
	'" . mysql_real_escape_string($image) . "')" ;

        mysql_query($sql, $conn)
          or die('Could not submit person; ' . mysql_error());
      
//if image true then upload image 
if ($image == true) {

require_once '../../includes/image_upload.php';

} 

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.