?
Solved

PHP / odbc connect error

Posted on 2006-06-01
4
Medium Priority
?
892 Views
Last Modified: 2013-12-12
Do you know if Microsoft's ODBC driver supports using remote datafiles?
 
We setup two DSNs on our server. One pointed to a datafile directory on the harddrive (C:/Datafile) and another pointed to a remote computer's datafile directory (\\pebbles\C\Datafile which was mapped by the ODBC configuration utility to Z: so it ended up pointing to Z:\Datafile).
 
When we tried to do a simple odbc_connect() in our php script we get a PHP warning: odbc_connect(): SQL error: [Microsoft][ODBC dBase Driver] '(unknown)' is not a valid path.
 
When we use the exact same code, but with the DSN that points to our harddrive's datafile, the script works.
 
Any assistance would be appreciated greatly.
0
Comment
Question by:garvism
  • 2
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 1500 total points
ID: 16814373
ODBC is not just a Microsoft technology.

I use ODBC to connect my web server to 3 different SQL servers on our network as well as 3 remote (through VPN to another city) SQL servers.

All using ODBC.

Do you have Microsoft Excel? If so, can you try using Excel's get external data facility. You may need to install Microsoft Query. This will allow you to test the ODBC connection outside of PHP, using MS technology.

Once you've proven you can connect to the remote server, you can use the DSN in PHP.

Also, you do not need to create a DSN. You can do all of that within PHP.

Each ODBC source has a different string (one of the downsides to ODBC).

e.g.

MS SQL Server = Driver={SQL Server};Server={$s_name_of_server};Database={$s_name_of_database}

and for dbase (http://www.carlprothman.net/Default.aspx?tabid=90#ODBCDriverForDBASE) ...

$r_conn = odbc_pconnect("Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=Z:/Datafile", $user_name, $password);

I don't know if a username and a password are required for dbase.
0
 

Author Comment

by:garvism
ID: 16817218
Thanks, RQuadling.  I will certainly try your suggestions and post back when I have results.
Stephanie
0
 

Author Comment

by:garvism
ID: 16842935
We have had success with PHp's ADOdb connection - so I'm closing this question and assigning points to RQuadling.
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16842988
There are MANY other ways to connect, they all do more or less the same thing. ODBC is not OOP, but ADOdb is via a COM interface.

You may find that using ADOdb considerably slower than using a more local mechanism. Every time you make a request, the COM interface has to be loaded. Sure the same is true with ODBC, but with ODBC, you can use something called persistent connections. This means for a set of credentials, only 1 connection is opened for the server and all traffic uses that connection. This is faster overall. Only ISAPI and FCGI SAPI's support persistent db connections. If you are using old-style CGI (normally for IIS and others), then you cannot use persistent connections and there is probably little advantage overall.

If you have come from VB, then ADOdb may be more familiar.

Good luck.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question