peppiv has asked for the wisdom of the Perl Monks concerning the following question:
My strict is up to date. I installed DBI, DBD:CSV. My file is Book1.csv and it's in the same directory as the script. I want it to print to screen all matches where city = Orlando (we're looking for a new basketball team owner). I'm running Apache/FreeBSD. Uploaded in ASCII chmod to correct permissions.#!/usr/bin/perl -w use strict; use DBI; print "Content-type: text/html\n\n"; $dbh = DBI->connect(qq{DBI:CSV:Book1:csv_sep_char=\\|}, {RaiseErro +r => 1} ); $dbh->{'csv_tables'}->{'Book1'} = {'file' => 'csv'}; $dbh->{'col_names' => ["timestamp", "email", "name", "address", "c +ity", "state", "zip"]}; $sth = $dbh->prepare("SELECT * FROM Book1 WHERE city = ?") or die +"Cannot prepare: " . $dbh->errstr(); $sth->execute('Orlando'); while (my @result = $sth->fetchrow_array()) { print "@result\n"; } $sth->finish(); $dbh->disconnect();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI Help!
by runrig (Abbot) on Jan 15, 2002 at 01:33 UTC | |
by peppiv (Curate) on Jan 15, 2002 at 01:40 UTC | |
by runrig (Abbot) on Jan 15, 2002 at 01:46 UTC | |
by peppiv (Curate) on Jan 15, 2002 at 01:57 UTC | |
by alienhuman (Pilgrim) on Jan 15, 2002 at 02:26 UTC | |
|
Re: DBI Help!
by jonjacobmoon (Pilgrim) on Jan 15, 2002 at 02:45 UTC | |
by peppiv (Curate) on Jan 15, 2002 at 02:49 UTC | |
|
Re: DBI Help!
by andye (Curate) on Jan 15, 2002 at 03:03 UTC | |
|
Re: DBI Help!
by tradez (Pilgrim) on Jan 15, 2002 at 01:55 UTC | |
|
Re: DBI Help!
by higle (Chaplain) on Jan 15, 2002 at 01:45 UTC | |
by peppiv (Curate) on Jan 16, 2002 at 00:00 UTC | |
by runrig (Abbot) on Jan 16, 2002 at 00:25 UTC | |
by peppiv (Curate) on Jan 16, 2002 at 18:47 UTC | |
by runrig (Abbot) on Jan 16, 2002 at 18:52 UTC | |
|
Re: DBI Help!
by perrin (Chancellor) on Jan 15, 2002 at 01:41 UTC | |
by peppiv (Curate) on Jan 15, 2002 at 01:52 UTC | |
|
Re: DBI Help!
by metadoktor (Hermit) on Jan 15, 2002 at 02:54 UTC |