in reply to Re: DBI Problem
in thread DBI Problem
#!/usr/bin/perl -w # perl modules use CGI; use DBI; use strict; use diagnostics; # setup CGI handle my $cgi = new CGI; # start HTML print $cgi->header; my $dsn = 'DBI:mysql:mydb:localhost'; my $db_user_name = 'mydbusername'; my $db_password = 'mydbpassword'; my $dbh = DBI->connect($dsn, $db_user_name, $db_password) or die "Coul +dn't connect to $dsn: $DBI::errstr"; my $sth = $dbh->prepare(qq{select user, topic, topictest from pagedata +}) or die "Couldn't prepare select: ", $dbh->errstr; $sth->execute() or die "Couldn't execute query: ", $dbh->errstr; while (my ($username, $topic, $topictext) = $sth->fetchrow_array()) { print "$username, $topic, $topictext"; } $sth->finish(); $dbh->disconnect();
thor
|
|---|