basm101 has asked for the wisdom of the Perl Monks concerning the following question:
Any ideas ?#!/biol/programs/perl/bin/perl -w use strict; use DBI; use CGI qw(:standard); #print "Content-type:text/html\n\n"; my($dbh,$sth,$count,$sql,$cgi); $cgi = new CGI; use CGI::Carp qw(fatalsToBrowser); $dbh = DBI->connect("DBI:mysql:host=myhost;database=mydb", "username","password", {PrintError =>0, RaiseError => 1})|| die "Database connection not +made: $DBI::errstr"; $sql = qq{SELECT * FROM name}; $sth = $dbh->prepare($sql); $sth->execute(); print header(), start_html(-title=>"My Database",-BGCOLOR=>"white",-FONT=>"Times") +; print STDOUT "<H1>My Database</H1><BR><BR>"; print STDOUT "<TABLE><TR><TH>Short name</TH><TH>Long name</TH></TR +>"; my ($id,$short_name,$long_name); $sth->bind_columns(undef,\$id,\$short_name,\$long_name); while($sth->fetch()){ print STDOUT "<TR><TD>$short_name</TD><TD>$long_name<TD></TR>" +; } print STDOUT "</TABLE>"; print p (end_html); $sth->finish(); $dbh->disconnect(); exit(0);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MySQL/DBI: Error if entry is not in the database
by dws (Chancellor) on Feb 05, 2003 at 18:31 UTC | |
by CountZero (Bishop) on Feb 05, 2003 at 20:29 UTC | |
|
Re: MySQL/DBI: Error if entry is not in the database
by powerhouse (Friar) on Feb 05, 2003 at 20:57 UTC | |
|
Re: MySQL/DBI: Error if entry is not in the database
by jasonk (Parson) on Feb 05, 2003 at 18:26 UTC | |
by Anonymous Monk on Feb 06, 2003 at 12:36 UTC |