$dbh = DBI->connect ("DBI:mysql:host=localhost;database=my_db",
"my_id", "my_pass",
{PrintError => 0, RaiseError => 1});
####
# Begin the Editing of the Guestbook File
open (FILE,"$guestbookreal") || die "Can't Open $guestbookreal: $!\n";
@LINES=;
close(FILE);
$SIZE=@LINES;
####
# Open Link File to Output
open (GUEST,">$guestbookreal") || die "Can't Open $guestbookreal: $!\n";
####
for ($i=0;$i<=$SIZE;$i++) {
$_=$LINES[$i];
if (//) {
if ($entry_order eq '1') {
}
{
print GUEST "INSERT INTO `mysql_db` (`Title`,
`Email`, `City`, `State`, `Country`,
`URL`, `Date`, `Description`, `rid`,
`dt_create`, `publish` ) VALUES (";
}
....
}
else {
print GUEST $_;
}
}
close (GUEST);
####
my $content;
open FILE, '<', $guestbookreal; # Open a filehandle FILE to $guestbookreal
while () {
chomp; # delete any EOL character(s)
$content .= $_; # Add the next line to the previous parts
}
$sth=$dbh->prepare($content);
$sth->execute();
$dbh->disconnect;
####
# Begin the Editing of the Guestbook File
####
$dbh->disconnect;
####
# Check that the things which must have a value have values:
if(defined $FORM{Description} and defined $FORM{Title})
{
my $sql = "INSERT INTO `mysql_db` (`Title`, `Email`,
`City`, `State`, `Country`, `URL`, `Date`,
`Description`, `rid`, `dt_create`, `publish`
) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
my $sth = $dbh->prepare($sql);
$sth->execute($FORM{Title}, $FORM{Email}, $FORM{City},
$FORM{State}, $FORM{Country},
$FORM{URL}, $FORM{Date},
$FORM{Description}, $FORM{rid},
$FORM{dt_create}, $FORM{publish});
$dbh->disconnect;
}
else
{
print "You must enter a Description and a Title";
}