if ($submit || $preview) { &Conn_to_DB_Forums; $SQL = "SELECT * from $forum_table WHERE (username='$username' AND user_password!='$user_password' AND user_active='1')"; &Do_SQL; &error(not_registered) unless ($pointer = $sth->fetchrow_hashref); I do some other stuff here...then disconnect. $sth->finish(); $dbh->disconnect; } if ($submit) { &Conn_to_DB; $SQL = "SELECT * from $op_tbl WHERE (prodID='$prodID' AND dateadded='$dateadded' AND prodtype='$prodtype' AND (username='$username' OR title='$titlefix'))"; # run SQL against the DB &Do_SQL; &error(no_spam) if ($pointer = $sth->fetchrow_hashref); $SQL = "INSERT INTO $op_tbl (username,name,email,location,features,usability,title,body,dateadded,prodID,prodtype) VALUES ('$username','$namefix','$emailfix','$locationfix','$features','$usability','$titlefix','$bodyfix','$dateadded','$prodID','$prodtype')"; # run SQL against the DB &Do_SQL; $pointer = $sth->fetchrow_hashref; $filename = $pointer->{'filename'}; }