I have a script that writes form data to a simple DBD:CSV file. I have tried a number of ways to write to this, and I am stumped. As you can see in the code, I have tried creating the file on the fly if it does not exist. I also tried creating a blank file using touch and then chmod 666 or 777.
I get no error messages, and my confirmation page shows the correct data. In the first case, the file is never created, and in the second, the file remains blank.

The company I host with provides cgiwrap, and I tried using that when running my script, with no luck, so it doesn't look like a permissions issue. I am using Carp(fatalsToBrowser), so if something is dreadfully wrong here, wouldn't it be reported back to me? Am I missing something obvious?
my $dir='../admin/'; my $table='EVENTS'; my $dbh= DBI->connect("DBI:CSV:f_dir=$dir")or die "Cannot connect: " . + $DBI::errstr; #if the table does not exist, make it #since we are using DBD:CSV, I am not sure that the field type/size de +clarations #are necessary, or even applied. Including them will make the code mor +e portable if #we move to mysql in the future. if (! -e "$dir$table") { print "making table $dir$table"; my $sth= $dbh->prepare ("CREATE TABLE $table (ukey CHAR(20), city CHAR(45), date CHAR(10), time CHAR(8), title CHAR(64), location CHAR(250), contact CHAR(64), email CHAR(60), phone CHAR(14) type CHAR(1))") or die "Cannot prepare: " . $dbh->errstr( +); $sth->execute() or die "Cannot execute: " . $sth->errstr(); } my $sth=$dbh->prepare(qq{INSERT INTO $table VALUES (?,?,?,?,?,?,?,?,?, +?)}) or die "Cannot prepare: " . $dbh->errstr(); $sth->execute(@fieldvals) or die "Cannot execute: " . $sth->errstr();
Thanks for your wisdom,
digger

In reply to DBD:CSV and creating a database by digger

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.