I am using Perl v. 5.10 and MySQL v.5.1.31 Community Server (GPL), Apache Server 2.2 on Windows XP Professional Service Pack 3
Given this 8 line segment of code from a Perl CGI script:
my $db = "gfr";
my $un = "gfr";
my $pw = "gfr";
my $dbH = "";
$dbH = DBI->connect("DBI:ODBC:$db",$un,$pw) ||
die "Got error when connecting to un=$un, pw=$pw, db=$db\n".DBI->errstr;
It executes perfectly when I run it from a command window.
i.e. perl -w prgNm.cgi
When I call the script from an HTML file like this:
<a href=http://localhost/gfr-bin/prgNm.cgi>Load new image filenames</a>
I get the error:
Got error when connecting to un=gfr, pw=gfr, db=gfr
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (SQL-IM002) at C:/Documents/Documents_20090101_to_20091231/Computing/GalleryForRent_Maintenance/gfr-bin/prgNm.cgi line 49.
If I comment out the two lines:
# $dbH = DBI->connect("DBI:ODBC:$db",$un,$pw) ||
# die "Got error when connecting to un=$un, pw=$pw, db=$db\n".DBI->errstr;
I get the expected "xxx" in the web browser (so I know that it does not lie with the Apache Server's httpd.conf file).
Would anyone have any ideas?
PS: To try to avoid using ODBC, I have tried to obtaiin a DBD-mysql module for Perl 5.10 and MySQL v5.1 but nothing I have found on the web works nor anything I have received from the MySQL forums.