AW: mysql perl connection problem

"Selke, Gisbert W." <[email protected]> Tue, 27 Jul 2010 16:28:24 +0200
Newsgroups gmane.comp.db.mysql.perl
Message-ID <DA5D2621C9566F488C32ACE506A7BB89012722F9@wido-exch01.wido.bv.aok.de>
> -----Urspr=FCngliche Nachricht-----
> Von: Jamal Nasir [mailto:[email protected]]=20
> Gesendet: Dienstag, 27. Juli 2010 15:52
> i have installed perl in windows.
> When i execute the following code:
>=20
> #!/usr/bin/perl
>=20
> # PERL MODULE
>=20
> use DBD::Mysql;
>=20
> # HTTP HEADER
> print "Content-type: text/html \n\n";
>=20
> # CONFIG VARIABLES
> $host =3D "127.0.0.1";
> $database =3D "shah569";
>=20
> $user =3D "jmlnsr";
> $pw =3D "ntr562";
>=20
> # PERL MYSQL CONNECT
> $connect =3D Mysql->connect($host, $database, $user, $pw);
> print 'Hello';
>=20
> I get following error in apache error log.
>=20
>=20
> Can't locate object method "connect" via package "Mysql"=20
> (perhaps you forgot to=20
> 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 =3D =
"DBI:mysql:database=3D$database;host=3D$hostname;port=3D$port";
    $dbh =3D DBI->connect($dsn, $user, $password);

\Gisbert

-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/[email protected]