Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Mar 2009
    Posts
    2

    Default Perl CGI and DBI, MySQL, DBI->connect

    Hi,
    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;
    print "xxx";
    exit;

    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:
    <p style="text-indent:5cm">
    <a href=http://localhost/gfr-bin/prgNm.cgi>Load new image filenames</a>
    </p>
    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?

    Thanks,
    Andynic
    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.

  2. #2
    Junior Member port80's Avatar
    Join Date
    Jul 2006
    Posts
    29

    Default

    You must commune with the monks my son.



    The Perlmonks that is!

    www.perlmonks.org

    Ask your question there.

    -Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •