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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.