Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL/DBI can't locate database!

Status
Not open for further replies.

woofy

Technical User
Oct 15, 2000
1
GB
Hi

I'm a first-timer at DBon MySQL & Perl. Rightly or wrongly I have placed a DB in my CGI-BIN however

$dbh = DBI->connect('dbi:mysql:WOOFY_01', '', '',);

cannot connect for

$sqlstatement="SELECT * FROM WOOF";
$sth = $dbh->prepare($sqlstatement);
$sth->execute ||
die "Could not execute SQL statement ... maybe invalid?";

to do its stuff.

Any help would be appreciated.

Cheers [sig][/sig]
 
# Database Variables
my $db_type = 'mysql'; # RDMS controlling the database
my $db_database = ''; # name of the database
my $db_username = ''; # username to access this database
my $db_password = ''; # password to access this database

# Database API
use DBI;

# Connect to Database
my $drh=DBI->install_driver($db_type);
my $dbh=$drh->connect($db_username,$db_database,$db_password) or die "Error connecting: $DBI::errstr\n";

# Do SQL statements
my $sqlstatement = "SELECT * FROM WOOF";
my $sth = $dbh->prepare($sqlstatement);
$sth->execute || die "Could not execute SQL statement ... maybe invalid?";
my @array = $sth->fetchrow;
$sth->finish;

# Disconnect from database
$dbh->disconnect; [sig]<p> Sincerely,<br><a href=mailto: > </a><br><a href= Anderson</a><br>CEO, Order amid Chaos, Inc.<br>
[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top