PB has asked for the wisdom of the Perl Monks concerning the following question:
I have the following setupuse strict ; use CGI qw(param); use diagnostics ; sub init { # Constants my $db = "edb"; my $server = "localhost"; my $user = "localuser"; my $password = "localpasswd"; # CGI Parameters my $Id = param("ID"); my $Fname = param("Fname"); # Connect to database $dbh->{RaiseError} = 1; my $dbh = DBI->connect("DBI:mysql:$db:$server", $user,$password); if (! $dbh) { print "Could not connect to $db on $server\n"; } # Prepare and run the query my $query="INSERT INTO clients values( \"$Fname\",\"$Id\") ;"; my $sth = $dbh->prepare_cached("$query") or die "Can't prepare stateme +nt: $dbh->errstr \n"; $sth->execute or die "Can't execute statement", $dbh->errstr ; $sth->finish; $dbh->disconnect(); } # End int();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Printing DBI errors from a CGI script
by perlplexer (Hermit) on Apr 18, 2002 at 20:04 UTC | |
by lestrrat (Deacon) on Apr 18, 2002 at 21:03 UTC | |
|
Re: Printing DBI errors from a CGI script
by tradez (Pilgrim) on Apr 18, 2002 at 20:01 UTC | |
|
Re: Printing DBI errors from a CGI script
by Ryszard (Priest) on Apr 19, 2002 at 05:24 UTC |