Looking for assistance in, as the title reads, accessing an Access database via PHP when the database is open. (Please bear with me as my knowledge of PHP, when used in conjunction with a database, is extremely sketchy at best.)
Using the code below, I can pull up a directory of employees. It's nothing fancy but it works and I'm still learning:
$conn=odbc_connect('Employees','','');
if (!$conn)
{exit("Connection Failed: " . $conn);}
$sql="SELECT * FROM tblEmployees WHERE CompanyID = '$comp' AND Active = Yes AND Generic = No ORDER BY LastName";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");}
echo "<table>";
echo "<tr><th>Name</th>";
echo "<th>Department</th>";
echo "<th>Email Address</th></tr>";
while (odbc_fetch_row($rs))
{
$compdept=odbc_result($rs,"Dept");
$empfirst=odbc_result($rs,"FirstName");
$emplast=odbc_result($rs,"LastName");
$empemail=odbc_result($rs,"ECAddress1");
echo "<tr><td>$emplast, $empfirst</td>";
echo "<td>$compdept</td>";
echo "<td>$empemail</td></tr>";
}
odbc_close($conn);
echo "</table>";
?>
The problem is that when someone has the database open on their computer, the connection fails.
There are a number of possible reasons that come to mind, but I was hoping that someone would be able to point out something I'm missing.
Eric