Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Problem with Apache, DBD::ODBC, MS Access, and backticks.

by jryan (Vicar)
on Sep 14, 2004 at 23:48 UTC ( [id://391024]=perlquestion: print w/replies, xml ) Need Help??

jryan has asked for the wisdom of the Perl Monks concerning the following question:

In an application I'm writing, I need to connect to an MS Access database (.mdb) thats on a network drive. I created an ODBC DSN just fine, wrote my chunk of code using DBI and DBD::ODBC, tested it from the command line, and everything seemed to work fine. However, when I try to use this same code from within the mod_perl application, I get:

DBI connect('perl_dbi','',...) failed: [Microsoft][ODBC Microsoft Acce +ss Driver] '(unknown)' is not a valid path. Make sure that the path +name is spelled correctly and that you are connected to the server on + which the file resides. (SQL-HY024)(DBD: db_login/SQLConnect err=-1)

Thinking that Apache was simply unable to handle paths on network drives, I separated the section into a standalone script and tried to shell out to it. However, I still get the same error, which doesn't make any sense at all to me since this script works fine by itself on the command line. I've tried changing the connect line to specify the file to connect to explicitly, but that still doesn't work.

I'm completely lost. Can anyone help?

Replies are listed 'Best First'.
Re: Problem with Apache, DBD::ODBC, MS Access, and backticks.
by BrowserUk (Patriarch) on Sep 15, 2004 at 00:30 UTC

    Isn't this a variation on the "webserver user id's are denied access to networked resources" problem?

    The fix is to change the account under which the service runs from the default to one that you give the rights required to access network shares. This is done through Start->admin tools->computer management->Services & applications->Services. Bring up the Properties dialog on the apache service, select the log on tab and fill in details for the userid/password to use. Stop/start the service.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

      Just tried it, but it doesn't help... thanks anyway.

Re: Problem with Apache, DBD::ODBC, MS Access, and backticks.
by jryan (Vicar) on Sep 15, 2004 at 20:50 UTC

    Just an update for the future: I was able to fix the problem by both a.) following BrowserUK's suggestion and b.) changing the ODBC path to use a UNC path instead of a mapped network drive path (to do this, type in the full UNC path under "Database Name" when it brings up the file explorer window.) I still can't believe using a UNC made it work, I would think it shouldn't make any difference.

      Mapped drivers are a user thing, PHP does not run as the user, hence no valid path.
Re: Problem with Apache, DBD::ODBC, MS Access, and backticks.
by jZed (Prior) on Sep 15, 2004 at 17:03 UTC
    Make sure the ODBC is set for a *system* DSN. Then connect with $dbh=DBI->connect("DBI:ODBC:$dsnname",$user,$pass,$flags);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://391024]
Approved by Crackers2
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-03-19 04:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found