3 messages in com.mysql.lists.perlRe: installation problem
FromSent OnAttachments
Nate05 Aug 2002 04:44 
Dwalu Z. Khasu05 Aug 2002 05:08 
Clinton Hogge05 Aug 2002 21:15 
Subject:Re: installation problem
From:Clinton Hogge (cli@western.net)
Date:08/05/2002 09:15:20 PM
List:com.mysql.lists.perl

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,