source: trunk/npemap.org.uk/perllib/NPEMap.pm @ 299

Last change on this file since 299 was 299, checked in by Dominic Hargreaves, 14 years ago

Oops!

File size: 774 bytes
RevLine 
[221]1package NPEMap;
2
3use vars qw(@ISA @EXPORT);
4use warnings;
5use strict;
6
7use vars qw($dbname $dbhost $dbuser $dbpass);
8
9use NPEMap::Config;
[299]10use DBI;
[221]11
12require Exporter;
13@ISA    = qw(Exporter);
[236]14@EXPORT = qw(setup_dbh print_html_err);
[221]15
16sub setup_dbh {
17    my $data_source = "dbi:Pg:dbname=$dbname";
18    $data_source .= ";host=$dbhost" if $dbhost;
19    return DBI->connect_cached($data_source, $dbuser, $dbpass);
20}
21
[236]22sub print_html_err($$) {
23    my $err = shift;
24    my $returnlink = shift;
25    print "Content-type: text/html\n\n";
26    print "<html><head><title>Error submitting</title></head>\n";
27    print "<body><p>The following error occurred whilst submitting data:\n";
28    print CGI::escapeHTML($err);
29    print "</p><p>$returnlink</p>\n";
30    print "</body></html>\n";
31}
32
[221]331;
Note: See TracBrowser for help on using the repository browser.