List:MySQL and Perl« Previous MessageNext Message »
From:Gisbert W. Selke Date:July 27 2010 2:28pm
Subject:AW: mysql perl connection problem
View as plain text  
> -----Ursprüngliche Nachricht-----
> Von: Jamal Nasir [mailto:mjamal_nasir@stripped] 
> Gesendet: Dienstag, 27. Juli 2010 15:52
> i have installed perl in windows.
> When i execute the following code:
> 
> #!/usr/bin/perl
> 
> # PERL MODULE
> 
> use DBD::Mysql;
> 
> # HTTP HEADER
> print "Content-type: text/html \n\n";
> 
> # CONFIG VARIABLES
> $host = "127.0.0.1";
> $database = "shah569";
> 
> $user = "jmlnsr";
> $pw = "ntr562";
> 
> # PERL MYSQL CONNECT
> $connect = Mysql->connect($host, $database, $user, $pw);
> print 'Hello';
> 
> I get following error in apache error log.
> 
> 
> Can't locate object method "connect" via package "Mysql" 
> (perhaps you forgot to 
> load "Mysql"
As the documentation for DBD::mysql points out (right at the start), the way to use DBI
and, in particular, the MySQL driver is this:
    use DBI;
    $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";
    $dbh = DBI->connect($dsn, $user, $password);

\Gisbert
Thread
mysql perl connection problemJamal Nasir27 Jul
  • AW: mysql perl connection problemGisbert W. Selke27 Jul