Hi Xu, Yilin, you asked about a script that complained:

> Undefined subroutine &DBI::dr::connect called at
> /usr/lib/perl5/site_perl/5.6.0/i386-linux/DBI.pm line 471.

I think the explicit use of DBD::mysql is causing the problem.  I 
don't have a mysql installed, but try commenting out that use line
as follows and see if the program works:

#! /usr/bin/perl -w
use strict;
use DBI;
# -----
# remove this line
# use DBD::mysql;
# -----
my $dbusername = 'test';
my $dbpassword = 'test';
my $sql;
my $dbh;
my $dbname = 'test';
$dbh = DBI->connect('DBI:mysql:'.$dbname, $dbusername, $dbpassword) ||
die "$DBI::errstr\n";
$sql = $dbh->prepare("INSERT INTO testac VALUES (11, 'youknow')");
$sql->execute;
$dbh->disconnect();

Good luck.

Stph

Reply via email to