[thelist] PHP Connect String

Hershel Robinson hershelr at netvision.net.il
Thu Apr 7 10:09:21 CDT 2005


I am a PHP newbie. Completely. Today is my first day. :)

The page I have is working on my local server, but on the live server, it
fails. The DB open fails it seems. This is my code:

$db = 'c:\\inetpub\\wwwroot\\XXXX\\db\\contacts.mdb';
$conn = new COM('ADODB.Connection');
echo $db;
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db");
echo $db;
// $conn->Open("DRIVER={Microsoft Access Driver (*.mdb)};Dbq=$db");
echo $db;

I put the echoes on there to clarify which line fails. The $conn->Open line
fails.

I have one Open line commented out, but in practice on my Win 2K Pro IIS 5
system (with the very latest PHP installed today) both lines work fine.

The host has a FAQ [1] as to how to connect to an Access DB via ASP:
<quote>
The first thing you need to do is to put your Access database in your
/databases directory. It's in a location that will prevent people from
downloading it from your site. When the database is in the /databases
directory, its filename is:

D:\Web\yourdomain.foo\databases\filename.mdb
</quote>

I tried using either of these connect strings:
$db = 'D:\\Web\\teachkidspeace.com\\www\\db\\contacts.mdb';
$db = 'D:\\Web\\teachkidspeace.com\\databases\\contacts.mdb';

both of which seem to me that they should work. www\db is where I orginally
had the DB and the DB is definitely there. HTTP and TableEditor (ASP) both
find it and it's writeable (via TableEditor). I also put a copy of the DB in
\databases to try that.

But PHP gives me: Unhandled Exception Code
or: Access Violation
depending on which $db value I use.

Any ideas? What's the next step?

Thanks.

[1] http://www.northcomp.com/support/article.aspx?ID=9



More information about the thelist mailing list