Yeah, the file is there & has the content I posted.
I even just changed the script to attempt an open on the file, and return an error if it wasn't available:
#!c:/apache/perl/bin/perl.exe -wT
BEGIN {
$| = 1;
open (STDERR, ">&STDOUT");
print qq~Content-type: text/html\n\n~;
}
use CGI qw/:standard/;
use strict;
use Data::Dumper;
use DBI;
my $foo = new CGI;
print $foo->header;
# Connect to the database, (the directory containing our csv file(s))
my $dbh = DBI->connect("DBI:CSV:f_dir=.;csv_eol=\n;");
my $content = '';
open (FILE,"c:/apache/htdocs/test2.csv") || die "unable to open file";
while (<FILE>) {
print $_;
}
close(FILE);
# Associate our csv file with the table name 'test2'
$dbh->{'csv_tables'}->{'test2'} = { 'file' => 'c:/apache/htdocs/test2.
+csv'};
# Output the name and contact field from each row
my $sth = $dbh->prepare("SELECT * FROM test2 WHERE name LIKE 'G%'");
$sth->execute() or die "Can't execute the query: $sth->errstr";
while (my $row = $sth->fetchrow_hashref) {
print("name = ", $row->{'Name'}, " contact = ", $row->{'Contact'}
+. "\n");
}
$sth->finish();
The file opens fine, it prints to the browser fine, but then is followed by the error about the missing first line etc.
*shrug*
Tackled this from a few different angles. Really wanted to use DBD::CSV vs. TEXT::CSV so that I would be able to do what I want with the data a LOT more efficiently since it's a script that I'm going to setup to run frequently on my server.
I may just end up coding it with TEXT::CSV and then recode it if I ever get DBD::CSV working :-|
Thx for the help all the same. I appreciate it!
Stenyj
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.