my $query; $query=qq(insert into MasterEpisode set \ ShowId ="$ShowID",\ title ="$p->{'ep_title'}",\ description ="$p->{'ep_description'}",\ uploaddate =localtime ); print p($query); $dbh->do("$query"); # I see a risk of a race condition here. I should see if I can get the ID while I insert the line. my $episodeid=$dbh->last_insert_id(undef,undef,"MasterEpisode",undef); print p("Episode id is $episodeid."); #### # $episodeid=$dbh->last_insert_id(undef,undef,'MasterEpisode',undef); $sth = $dbh->prepare(qq(select LAST_INSERT_ID() from MasterEpisode)); $sth->execute(); @episodeid=$sth->fetchrow_array(); $episodeid=$episodeid[0]; print p("Episode id is $episodeid.");