in reply to Using mysql with perl
Here is a short bit of code to try and see if everythings working as it should, you'll have to change to your needs...
#!/usr/bin/perl -w use strict; use DBI; my $dbtype = "mysql"; my $dbname = "mydb"; my $dbuser = "username"; my $dbpass = "userpassword"; my $dbh = DBI->connect("DBI:${dbtype}:${dbname}", "$dbuser", "$dbpass" +) || die $DBI::errstr; my $sql = "SELECT foo, bar FROM mytable"; my $sth = $dbh->prepare($sql); $sth->execute() || die $DBI::errstr; while (my ($foo, $bar) = $sth->fetchrow()) { print "Column foo contains: $foo\n"; print "Column bar contains: $bar\n"; } $sth->finish(); $dbh->disconnect() || warn $DBI::errstr;
Hopefully that will get you started.
barrd
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Using mysql with perl
by kiat (Vicar) on Jun 07, 2003 at 12:32 UTC | |
by barrd (Canon) on Jun 07, 2003 at 12:39 UTC |