in reply to Re: Voting script using MySQL and DBI
in thread Voting script using MySQL and DBI

I don't see you issuing a disconnect, so perhaps it's possible to reuse $dbh, and avoid reconnecting from within print_form.

That should AFAIK be correct, as long as it is one Db then issuing the connect() command once is sufficient for multiple queries.

As for the error info try something like:

my $dbh = DBI->connect ("DBI:${dbtype}:${dbname}", "$dbuser", "$dbpass +") || die $DBI::errstr;
This will give you more detail as 'to what is going on'.

Replies are listed 'Best First'.
(jeffa) Re: Voting script using MySQL and DBI
by jeffa (Bishop) on Aug 31, 2002 at 17:50 UTC
    Or even better:
    my $dbh = DBI->connect( "DBI:${dbtype}:${dbname}", $dbuser, $dbpass), {RaiseError => 1}, ); # oops! $dbh->prepare('slecet foo from baz');
    Now every database method will raise an error automatically if one is encountered - Laziness! And get out of the habit of putting quotes around variables when you don't need to.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      G'day jeffa

      I'll certainly take this on board, but why is this ?

      "And get out of the habit of putting quotes around variables when you don't need to."

      Cheers
      lagrenouille

        Stringifying some things (objects, especially) ruins them for normal use. Plus, it's useless.