Whenever I run the following script from the command line, it works fine, but if I run it on the web server from a web browser, I get the following error in my apache error.log:
[Fri Jul 17 11:26:50 2009] [error] [client 192.168.xxx.xxx] DBI connect('my_dsn','user',...) failed: [INTERSOLV][ODBC Informix driver][Informix]Unable to load locale categories. (SQL-HY000)#!c:/perl/bin/perl use strict; use Template; use CGI qw(fatalsToBrowser); use DBI; #use POSIX qw(locale_h); #setlocale(LC_CTYPE, "en_US.CP1252"); $CGI::POST_MAX = (1024 * 100); # max 100K posts $CGI::DISABLE_UPLOADS = 1; # no uploads my ($dbh, $sth); my $Error_Message = "\nThere Was A Problem Connecting To The Database\ +n"; my $dbusername = 'user'; my $dbpassword = 'password'; my $dsn = 'my_dsn'; my $cgi = new CGI; my $query = shift; # get command line param $query ||= $cgi->param('q') unless defined $query; # unless got comman +d line param, grab cgi param # if query param was not set, use default unless ( $query ) { $query = "none"; } $query =~ /([a-zA-Z0-9-]+)/g; $query = $1; $dbh = DBI->connect("dbi:ODBC:$dsn", $dbusername, $dbpassword, {'RaiseError' => 1, 'PrintError' => 1} ) || die "$Error_Message $DBI::errstr"; my $sql = qq{select T2.item_num c1, T1.desc_1 c1, T2.on_hand c3 from item T1, item_w T2 where T2.item_num='$query' and T1.item_num = T2.item_nu +m}; $sth = $dbh->prepare($sql); $sth->execute() || die $sth->errstr; my @results; while (my @ref = $sth->fetchrow_array) { # 0=item_num, 1=desc_1, 2=on_hand push (@results, $ref[0] . ", " . $ref[1] . ", " . $ref[2]); } $sth->finish(); $dbh->disconnect(); my $tt = Template->new({INCLUDE_PATH => '../src'}) || die Template->er +ror(), "\n"; my $vars = { results => \@results, query => $query, }; print $cgi->header(-type=>"text/html"); print $tt->process('elite_inventory.tt', $vars) || die $tt->error(), " +\n";
I tried setting the locale in perl, but that didn't help. Also, nowhere I could find where to set the locale for the ODBC Informix driver (I looked in Administrative Tools - Data Sources (ODBC)).
In reply to DBI connect('my_dsn','user',...) failed: [INTERSOLV][ODBC Informix driver][Informix]Unable to load locale categories. (SQL-HY000) by albi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |