You should be assigning DBI->connect() to $dbh.  I'm not sure what all
arguments you need for DBD::Postgresql (run perldoc DBD::Postgress to see),
but you should at least include error checking of some sort (run perldoc DBI
for examples).
--
Mac :})
** I normally forward private database questions to the DBI mail lists. **
Give a hobbit a fish and he'll eat fish for a day.
Give a hobbit a ring and he'll eat fish for an age.
----- Original Message -----
From: "Christine Kluka" <[EMAIL PROTECTED]>
To: "Ronald J Kimball" <[EMAIL PROTECTED]>; "Chase Michael A."
<[EMAIL PROTECTED]>
Cc: "Neil Lunn" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, June 21, 2001 05:14
Subject: Re: DBI Connect Failure


> Ron, Michael,
>
> Thanks, using option 1, all the syntax errors are cleared up!  I'm not
> too clear on where the print statements are needed, so if you could
> refer me to some documentation about this,
> I'd appreciate it.
>
> However I still can't connect to my sample Postgres database.
>
> On:
>
> package PgSQL;
> use strict;
> use PgSQL::Cursor;
>
> use CGI qw(:standard);
>
> my $dbh;
> $dbh = db_connect("mydb") or die "Error: $PgSQL::error";
> print $dbh;
>
> I get:
> "Undefined subroutine &PgSQL::db_connect called"
>
> Thanks again for your help,
>
> Christine
>
> Ronald J Kimball wrote:
> >
> > On Wed, Jun 20, 2001 at 03:47:31PM +0200, Christine Kluka wrote:
> > > Neil,
> > >
> > > Thanks, I added "my" to this variable and to the array and hash
> > > declarations in my "row" subroutine -- this eliminated the "not
> > > imported" errors.
> > >
> > > Now when I execute the script I am prompted for explicit package names
> > > for each instance of a scalar, array or hash.  I believe that if I
> > > declare the fully qualified package name where the database handler is
> > > invoked, this should take care of the problem.  I've tried several
ways
> > > of doing this, but they all fail on syntax or for more serious
reasons.
> >
> > That's another error that means you haven't declared your variables.
> >
> > When you use strict 'vars', you have three options for each variable.
> >
> > Declare it with my:
> >
> >   my $lexical_variable;
> >   $lexical_variable = 7;
> >   print $lexical_variable;
> >
> > Declare it with use vars:
> >
> >   use vars qw/ $global_variable /;
> >   $global_variable = 7;
> >   print $global_variable;
> >
> > Specify the package name every time you use it:
> >
> >   $main::global_variable = 7;
> >   print $main::global_variable;
> >
> > Most people prefer the first two options.
> >
> > Ronald

Reply via email to