I am having issues getting a simple DBI connection using perl to work.
I put a place checker to see if the database handle is undefined and it always comes out undefined. Are there any blatant errors? I'm assured that the info I enter is correct, as I'm using it in a php script.
#!/usr/bin/perl -w
use warnings;
print "Content-Type: text/html\n\n";
use DBI;
# Connecting to the database
# Replace DATABASENAME with the name of the database,
# HOSTNAME with the hostname/ip address of the MySQL server.
$drh = DBI->install_driver("mysql");
$dsn = "DBI:mysql:database=db_name;host=host_name";
$dbh = DBI->connect($dsn,"username","password");
if(defined $dbh)
{
print "Yes<br />";
}
else
{
print "No<br />";
}
# Select the data and display to the browser
$sth = $dbh->prepare("SELECT * FROM customer");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref()) {
print "Found a row: id = $ref->{'cid'}";
}
$sth->finish();
# Disconnect from the database.
$dbh->disconnect();
connect()with{ RaiseError => 1 }?$drh = DBI->install_driver("mysql");is useless