Yeah, go ahead and steal the connection strings, that's why I posted
them :)
Also check out:
The first one has sample connection strings for lots of databases and
the second seems to have info on dbase5 specifically.   If not,
searching the web should work.  The connection string should be the same
or very similar to what ASP and other such things use.
As for not being able to access MDB files from PHP..   I really think
there's got to be a way.  I could be wrong, but when I was reading
around it seems like PHP doesn't like to do DSNless connections which is
why I started using ADOdb because it let me do DSNless connection
strings and all.  Maybe it's just the fact that most people use ODBC
sources to connect and aren't used to dealing with DSNless connections
that they're telling you that it won't work without ODBC or some other
intermediary.  Worth trying ADOdb though I think.
realpath is a good idea and it's something I used when I used to do ASP
in order to do the DSNless connections.  You kind of have to anyway
because you need the actual path of the MDB file that you're using.
I actually had a hosting company try to charge me $35 apiece for
"database setup fees" something like 6 months after I set up some ASP
with MDB using DSNless connections.   I argued with them that they
didn't set anything up, I did.   They wanted $35 to set up an ODBC
source (and to cover part of the server load that database connections
were likely to cause I guess).  But since I circumvented that, they
couldn't legally justify themselves in charging me the money and ended
up refunding the auto-charge to my credit card.
Something to think about for anyone settnig up PHP or ASP stuff with a
DSNless connection on a web hosting site.
        -----Original Message-----
        From: Alex Gemmell [mailto:[EMAIL PROTECTED] 
        Sent: Wednesday, May 12, 2004 10:27 AM
        To: 'PHP List'
        Cc: Gryffyn, Trevor
        Subject: RE: [PHP-DB] Linux/PHP/Access Database - oh boy :(
        Thank you Trevor!
        Funny you should mention ADOdb.  I just d/l it and uploaded it
to my web site!  I am working through the docs now.  I was losing hope
because I couldn't find what I was looking for but if you don't mind I
will help myself to your connection string:
        case "OtherDB":
            # Sample connect string to Access MDB file
            $myDSN="PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver
        I have been using the realpath function of PHP in other
connection strings to map the path from the server root to the database
location.  I assume will work fine here:
          $myDSN="PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver
(*.mdb)}; Dbq=". realpath("prices/mydb.mdb") .";UID=;PWD=;";
        I'm still not sure this will work.  I'm getting a lot of
information from people saying a .mdb file (the MS Access database) just
can't be accessed this way and I should use an intermediate database
format, like .dbf which can be made by exporting the database out of MS
Access into  "dbase 5".
        Does anyone know what the connection string for a .dbf (dbase 5)
format database is?
        |:| Reply-to: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>  |:|

        From: Gryffyn, Trevor [mailto:[EMAIL PROTECTED] 
        Sent: 12 May 2004 15:09
        To: PHP List
        Cc: Alex Gemmell
        Subject: RE: [PHP-DB] Linux/PHP/Access Database - oh boy :(
        First, I don't think you are likely to use COM calls on a linux
box since COM and DCOM are MS things aren't they?   Even if not, it
might require some configuration on the server end which you can't do.
        I use the ADOdb database library for PHP in all the things I do:
        I have a file that has all my connect strings in a
switch/case statement that dynamically changes the connect string.
        I think you can connect DSNLess to an Access database this way.
        I'll paste a stripped down version of the to my
message since I don't know if this list accepts attachments.   Let me
know if you have any questions.. good luck!
        $db = &ADONewConnection("ado_mssql");
        switch ($database) {
          # Cargo System databases
          case "PhotoGallery":
            # Where the photos are stored
          case "UserLogin":
            # Where the user login information is
            $myDSN="PROVIDER=MSDASQL;DRIVER={Microsoft ODBC for
          case "OtherDB":
            # Sample connect string to Access MDB file
            $myDSN="PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver
        if ($sqlquery <> "") {
          $rs = $db->Execute($sqlquery);
          if ($rs === false) {
            print "<h2>Error: (" . $db->ErrorNo() . ") " .
$db->ErrorMsg() . "</h2><br>\n";
          } else {
            $arr = $rs->GetArray();
            print "Status: (" . $db->ErrorNo() . ") " . $db->ErrorMsg()
. "<br>\n";
        } else {
          $rs = $db->Execute($sql);
          if ($rs === false) {
            print "<h2>Error: (" . $db->ErrorNo() . ") " .
        $sqlquery = "";
        $sql = "";
                -----Original Message-----
                From: Alex Gemmell [mailto:[EMAIL PROTECTED] 
                Sent: Wednesday, May 12, 2004 8:12 AM
                To: PHP List
                Subject: [PHP-DB] Linux/PHP/Access Database - oh boy :(
                Hello all,
                I am fairly new to Linux/PHP so please bear with me.  I
have an awfully awkward problem to solve - a stop gap solution for the
next 6 months until we have out in-house servers set up and running.  I
also have a very short timeframe to sort this out.  I am using PHP on a
remotely hosted Linux web server to build my website, however I have
been given a MS Access database to use!  Despite my best efforts (and
two days Google trawling) I haven't found a suitable solution so I am
turning to your collective knowledge...
                First things first - I do not run the server and cannot
install any new tools on to it (I cannot access the folders above my web
root).  There are lots of suggestions on the net about installing
MDBTools and UnixODBC RPM
( - but that involves
the admin who won't do it!  I can, of course, put scripts that may help
in the actual web folder and reference them if anyone has any ideas...
                I know I must use a DSN-less connection.  I first tried
connecting directly to the mdb file using:
                       $conn = new COM("ADODB.Connection") or die
("Cannot create ADODB Connection object."); 
                       //$connstr =
"PROVIDER=MSDASQL;DBQ=/prices/mydb.mdb;"."DRIVER={Microsoft Access
Driver (*.mdb)};" 
                       //$connstr = "Provider=Microsoft,.Jet.OLEDB.4.0;
Data Source=". realpath("prices/mydb.mdb") ." ;";
                       // I've never got the above two connection
strings to work but I include them for completeness and in case any
realises they might help me!
                       $connstr = "DRIVER={Microsoft Access Driver
(*.mdb)}; DBQ=". realpath("prices/mydb.mdb") ." ;";
                This worked on my localhost running IIS 5
(unsurprisingly) but fell over immediately on the Linux box.  I am told
this is because COM support in PHP before version 4.3.x is buggy (he PHP
version installed on the server is 4.1.2).  Is this true?  Will
upgrading to version 4.3.x solve all my problems?
                Also, I heard that converting the .mdb file to a .dbf
file might help - but how do I connect to that with PHP?  The PHP manual
says this about dbase functions:
                "These functions allow you to access records stored in
dBase-format (dbf) databases. There is no support for indexes or memo
                That's no good because I have long text fields in the
Access database that are of type "memo"!
                The Manual also says "we recommend that you do not use
dBase files as your production database" - eek!  It's only a small
database (one table with about 50 records, each with no more than 20
fields) so hopefully it will suffice.
                Am I right in thinking I have very few options?   I
don't want to move over to ASP (would that even help?) because it means
learning VBScript and I don't have a lot of time.  Also, I can't use
another database (e.g. MySQL) cos the server admin is NOT helping me and
won't install anything new.
                I know 99% of you will want to tell me to just back out
of this horrible tangle and take a different route, but is there one
person out there who can help me get through this nightmare?
                Thank you!
                Alex Gemmell
                |:| Reply-to: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>  |:|
                Or call me for free using Skype: 

Reply via email to