{ # Get the new prospect my $prospect = shift; # Connect to the database my $dbh = DBI->connect('DBI:mysql:menagerie', 'menagerie') or die "Couldn't connect to database:" . DBI->errstr; # Set all of the variables that we need to pass to MySQL my @data = qw/ name address address2 state city phone phone2 phone3 phone4 phoneType phone2Type phone3Type phone4Type email url interestLevel designFirm hostingFirm companyName /; my @insert_data; my $place_holders = '?,' x @data; chop $place_holders; # remove trailing comma foreach ( @data ) { no strict; my $method = $data[$_]; push @insert_data, $prospect->$method; } # Insert the new prospect in the database my $sth = $dbh->prepare("INSERT INTO prospect VALUES ( $place_holders )" ); # Execute the statement $sth->execute( @insert_data ) or die print DBI->errstr; # Lets get the prospect id that we just added back my $ID = $dbh->{'mysql_insertid'}; return $ID; }