Hello,
I recently used the ppm feature on my activeperl (Win32) to install both
the DBI package and the DBD-mysql modules. looking through the
documentation this seems to be all i need to do to access MySQL through
perl. However When i try to run my script i get an error that says the
following:
Global symbol "$dbh" requires explicit package name at dbi.pl
the entire script reads as follows:
#!c:/perl/bin/perl.exeuse strict;use DBI;$dbh =
DBI->connect("DBI:mysql:database=mvc2;host=localhost",
"", "", {RaiseError => 1});$dbh->do("CREATE TABLE foo (id INTEGER, name
VARCHAR(20)");
What is the problem? How do i resolve it?
Whenever you say "use strict;" in perl (which is always a good idea), you
need to declare all of your variables. In this case, change the "$dbh =
DBI..." line to "my $dbh = DBI...".
Hope that helps,
Regards,