awohld has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -wT use strict; use CGI; use DBI; use CGI::Carp qw(fatalsToBrowser); my $upload_dir = "/home/mine/upload"; my $query = new CGI; my $filename = $query->param("filename"); my $to = $query->param("to"); my $from = $query->param("from"); my $expire = $query->param("expire"); my $comments = $query->param("comments"); my $uldate = time; my $expdate; if ($expire eq 1) {$expdate = $uldate + 86400;} if ($expire eq 2) {$expdate = $uldate + 172800;} if ($expire eq 3) {$expdate = $uldate + 259200;} if ($expire !~m/^(1|2|3)$/) { print "Content-type: text/html\n\nDon't tamper with me!"; die; } $filename =~ s/.*[\/\\](.*)/$1/; ##Start database connections ############################## my $database = "live_databox"; my $db_server = "localhost"; my $user = "user"; my $password = "pass"; ##Connect to database, insert statement, & disconnect ##### my $sth; my $dbh = DBI->connect("DBI:mysql:$database:$db_server", $user, $passw +ord); my $statement = "INSERT INTO databox (filename,to,from,comments,uldate +,expdate) VALUES (?,?,?,?,?,?)"; $sth = $dbh->prepare($statement) or die "Couldn't prepare the query +: $sth->errstr"; my $rv = $sth->execute($filename,$to,$from,$comments,$uldate,$expdate) + or die "Couldn't execute query: $dbh->errstr"; $sth->finish; $dbh->disconnect; ######################################################### my $upload_filehandle = $query->upload("filename"); open UPLOADFILE, ">$upload_dir/$filename"; binmode UPLOADFILE; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: What is wrong with this DB insert, place holder problem?
by CountZero (Bishop) on May 14, 2005 at 08:23 UTC | |
|
Re: What is wrong with this DB insert, place holder problem?
by Animator (Hermit) on May 14, 2005 at 10:41 UTC | |
by awohld (Hermit) on May 15, 2005 at 02:55 UTC | |
|
Re: What is wrong with this DB insert, place holder problem?
by bradcathey (Prior) on May 14, 2005 at 13:12 UTC |