Hi
LameNerd.
The syntax you tried to use has changed. I took the liberty of including a small, simple, (and tested) code sample ( ActiveState 5.8.0, DBI version 1.37, MySQL 4.0.1).
#!/usr/bin/perl -w
use strict;
use DBI;
my $DSN = "DBI:mysql:database=testDB";
my $dbh = DBI->connect( $DSN, "xxx", "xxx" ) or die "$DBI::errstr";
my $sth = $dbh->prepare("select * from teams");
$sth->execute();
while( my $ref = $sth->fetchrow_hashref() ) {
print "$ref->{'wins'} $ref->{'losses'}";
}
$sth->finish();
$dbh->disconnect();
In case you're interested, here are some resources:
Title:Programming the Perl DBI
ISBN:1565926994
List Price:$34.95
Title:Mysql and Perl for the Web
ISBN:0735710546
List Price:$44.99
Title:MySQL, Second Edition
ISBN:0735712123
List Price:$49.99
http://www.perl.com/lpt/a/1999/10/DBI.html
http://www.devshed.com/Server_Side/Perl/Carping/print_html
http://www.eskimo.com/~ericj/personal/postgresql/sql1.htm
http://www.eskimo.com/~ericj/personal/postgresql/sql2.htm
http://www.eskimo.com/~ericj/personal/postgresql/sql3.htm
Hope these help,
If you have any more questions, don't hesitate to ask.
Thanks,
-Katie
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.