Nomad
03-25-2004, 05:43 AM
Hi,
Could someone please tell me the correct syntax to retrieve an auto incremented id after an insert in PERL.
The code I have is :-
# Connect to the database
my $dbh = DBI->connect("DBI:mysql:database=$config->
{dbname};host=localhost", "$config->{dbuser}",
"$config->{dbpass}", {'RaiseError' => 1});
# Insert member record
$dbh->do("INSERT INTO members (password,email,etc....)
VALUES ('$encpass','$email',etc....)");
$uid = $sth->{insertid}; ?????????????
# Disconnect from database
$dbh->disconnect();
but I do not get anything back. I have also tried :-
SELECT LAST_INSER_ID();
but keep getting back "0".
Help please
Could someone please tell me the correct syntax to retrieve an auto incremented id after an insert in PERL.
The code I have is :-
# Connect to the database
my $dbh = DBI->connect("DBI:mysql:database=$config->
{dbname};host=localhost", "$config->{dbuser}",
"$config->{dbpass}", {'RaiseError' => 1});
# Insert member record
$dbh->do("INSERT INTO members (password,email,etc....)
VALUES ('$encpass','$email',etc....)");
$uid = $sth->{insertid}; ?????????????
# Disconnect from database
$dbh->disconnect();
but I do not get anything back. I have also tried :-
SELECT LAST_INSER_ID();
but keep getting back "0".
Help please