How to recall the last inserted id?
Posted: Fri Oct 24, 2003 2:45 pm
Hi I am using Posgresql as my backend. I am wondering how can I recall the last inserted id?
I believe in mysql is :-
$empid = mysql_insert_id();
I need to associate the last inserted id with a cookie for a quiz page. My current code goes like this:-
$sql = "INSERT INTO person
(first_name, last_name, email, birthdate, status, org_id)
VALUES ('$first_name', '$last_name', '$email', '$birthdate', '$status', '$org_id')";
$result = pg_query($sql);
$person_id = pg_insert_id();
setcookie('reg_id', $person_id, 0, '/');
I am getting an error if i use pg_insert_id()
Any help will be highly appreciated.. Thanks
I believe in mysql is :-
$empid = mysql_insert_id();
I need to associate the last inserted id with a cookie for a quiz page. My current code goes like this:-
$sql = "INSERT INTO person
(first_name, last_name, email, birthdate, status, org_id)
VALUES ('$first_name', '$last_name', '$email', '$birthdate', '$status', '$org_id')";
$result = pg_query($sql);
$person_id = pg_insert_id();
setcookie('reg_id', $person_id, 0, '/');
I am getting an error if i use pg_insert_id()
Any help will be highly appreciated.. Thanks