#!/usr/local/bin/perl -wT
use DBI;
use CGI::Carp qw(fatalsToBrowser carpout);
use strict;
use warnings;
my $db_user = "xxx";
my $db_password = "xxx";
my $db_table = "table1";
my $db = "mysql";
my $database = "database1";
my %Attr = (RaiseError => 1, PrintError => 1, Taint => 1, AutoCommit => 1);
my $found = 0;
print "Content-type:text/html\n\n";
# Is MySQL DBD Installed ?
my @driver_names = DBI->available_drivers;
foreach (@driver_names) {
if ($_ =~ /$db/) {
my $found = 1;
last;
}
}
if (!$found) {
print "DBD:$db not found please install\n";
}
$database = "DBI:$db:$database";
eval {$dbh = DBI->connect("$database", "$db_user", "$db_password", \%Attr) || die
$DBI::errstr};
if ($@) {
print "Unable to Connect to $database with $db_user/$db_password\n";
exit;
}
$rc = $dbh->disconnect();
Hope that helps.
Philip
Girl, you?re my angel, you?re my darling angel
Closer than my peeps you are to me, baby
Shorty, you?re my angel, you?re my darling angel
Girl, you?re my friend when I?m in need, lady
On Fri, 30 Mar 2001, Nuno Medeiros wrote:
>
> hello,
>
> I'm new in perl dbi. i have a linux RH7 and Oracle 8.1.7.
> I want to write a script that runs from a browser.
>
> my first script is only to test the DB connection and works fine if i run it
> from the shell.
> if i run it from a browser, it does the DBI->available_drivers() but it
> does'nt connect to the DB.
> Does any one have any idea to help me?
>
> Thanks in advance
> Nuno
>
>
>
> --------------------------------
> publico.pt
> Nuno Medeiros
> [EMAIL PROTECTED]
>
>
>