Re: DBI setup problem

[email protected] ("Hendrik Schumacher")
Newsgroups perl.dbi.users
Message-ID <[email protected]>
That's no DBI issue.

You have to declare the variable $dbh using my, local or our before using
it. Example:

my $dbh = DBI->connect(...

Alternatively you could omit "-w", "use warnings" and "use strict" to make
your script run without special variable declarations.

Hendrik

Am Mi, 9.06.2010, 00:13, schrieb [email protected]:
> I am running Ubuntu 10.04 LTS and perl, v5.10.1.
>
> I am attempting to test perl access to a mysql database with the following
> code:
>
> 	#!/usr/bin/perl -w
>
> 	use strict;
> 	use warnings;
> 	use DBI;
>
> 	my($USAGE) = "$0 DUMMY\n\n";
>
> 	unless(@ARGV) { die $USAGE; }
>
> 	$dbh = DBI->connect('DBI:mysql:friends', 'rich', 'MarySue'
> 			   ) || die "Could not connect to
>                                      database: $DBI::errstr";
> 	# (insert querys here...)
> 	$dbh->disconnect();
>
> When executed the program produces the following results:
>
> 	rich@rich-desktop:~/Documents/perl/friends$ ./email01.pl
> 	Global symbol "$dbh" requires explicit package name at ./email01.pl line
> 23.
> 	Global symbol "$dbh" requires explicit package name at ./email01.pl line
> 26.
> 	Execution of ./email01.pl aborted due to compilation errors.
> 	rich@rich-desktop:~/Documents/perl/friends$
>
> What am I doing wrong?
>
>
> Rich Price [email protected]
> --------------------------------------------
> The optimist thinks that this is the best of
> all possible worlds. The pessimist knows it.
>                        J. Robert Oppenheimer
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.