PHP MS Microsoft Access 97 ODBC file already in use., SQL state S1000 database

Benny Hanna

New member
windows apache iis server 2003? Hello,

PHP and the database are communicating normally, however i am in a particular bind that i hope can be alleviated in some fashion...

I've been asked to duplicate a site that already exists which has Access 97 databases.

Although it would be my preference, I was asked not to convert the databases to MySQL and to continue using Access DBs. This also is what leads to my problem...

Other individuals are using forms in this same Access DB (being used by the PHP) to update records at any given time of the day.

While the access DB is not open, the site works fine. However when the database is open, it is unable to make the connection (because the file is open on someone's machine, full error at the end of this post).

When it comes to this database, the PHP code will not be writing anything to the DB, the data will only be read.

I am looking for a solution so that, even if that Access file is open by another user on the local network, the PHP will still be able to connect to and simply read data from the DB. If you can have it to also write to the DB, that would be spectacular, but it is not necessary.

i know what i'm doing with PHP + MySQL, but this MS Access stuff is certainly a pain in the ass and i was afraid i would run into this issue.

many thanks in advance.


note: while this is being tested on Apache (as you can see in the example) it will be served through IIS, i don't see if that matters, but i figured i'd mention it.





Warning:



Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Could not use '(unknown)'; file already in use., SQL state S1000 in SQLConnect in C:\Program Files\Apache Group\Apache2\htdocs\derp.php on line 5

Code:



< ? php
$conn=odbc_connect('testdb','user','pass');
if (!$conn)
{exit("Connection Failed: " . $conn);}
$sql="SELECT * FROM testtable";
$rs=odbc_exec($conn,$sql) or die($error);
if (!$rs)
{exit("Error in SQL");}
echo "<table><tr>";
echo "<th>Companyname</th>";
echo "<th>Contactname</th></tr>";
while (odbc_fetch_row($rs))
{
$compname=odbc_result($rs,"fielda");
$conname=odbc_result($rs,"fieldb");
echo "<tr><td>$compname</td>";
echo "<td>$conname</td></tr>";
}
odbc_close($conn);
echo "</table>";
? >
 
Back
Top