LoadModule perl_module modules/ApacheModulePerl SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI PerlSendHeader On #### #!perl print ("Content-type: text/html\n\n"); use strict; use vars qw($query $dsn $driver $db_username $db_password $dbh); require 5.006; $| = 1; ($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); ($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); use CGI qw(:standard); use CGI::Carp 'fatalsToBrowser'; $CGI::POST_MAX = (1024 * 0); $CGI::DISABLE_UPLOADS = 1; $query = new CGI; use DBI(); $driver = "mysql"; $dsn = "DBI:$driver:database=shapeshifter;host=localhost;port=80"; $db_username = "nobody"; $db_password = ""; warn "Before DBI->connect(): [$$]"; $dbh = DBI->connect($dsn, $db_username, $db_password) or die sprintf "Error: %s.\n", DBI->errstr; warn "After DBI->connect() [$$]"; my $sth = $dbh->prepare("SELECT * FROM frontpage"); $sth->execute(); while (my $ref = $sth->fetchrow_hashref()) { print qq~Found a row: id = $ref->{'serial_number'}, name = $ref->{'position'}
~; } $sth->finish(); $dbh->disconnect(); if ($ENV{'MOD_PERL'}) { print "Mod_perl is installed on this server: $ENV{'MOD_PERL'}

\n"; } else { print "Mod_perl is not installed on this server

\n"; } ##
## [Tue May 22 05:19:57 2001] nul: Before DBI->connect(): [2576] at e:/pad/htdocs/internet/system/db_test.pl line 20.
[Tue May 22 05:19:58 2001] nul: DBI->connect failed: Can't connect to MySQL server on 'localhost' (10061) at e:/pad/htdocs/internet/system/db_test.pl line 21
[Tue May 22 05:19:58 2001] [error] Error: Can't connect to MySQL server on 'localhost' (10061).