I'm having a problem in connecting my access database using php. The wampserver displays a message of Parse error. I have connected my access db through control pannel's option administrative tools,but no output.plz help me....
The server shows the following message:
Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Cannot open database '(unknown)'. It may not be a database that your application recognizes, or the file may be corrupt., SQL state S1000 in SQLConnect in E:\wamp\www\New Folder\my.php on line 5
Connection Failed:

<html>
<body>

<?php
$conn=odbc_connect('mgdatabase','','');
if (!$conn)
  {exit("Connection Failed: " . $conn);}
$access="SELECT * FROM Student";
$rs=odbc_exec($conn,$access);
if (!$rs)
  {exit("Error in access");}
echo "<table><tr>";
echo "<th>StudentName</th>";
echo "<th>Contactname</th></tr>";
while (odbc_fetch_row($rs))
  {
  $compname=odbc_result($rs,"FirstName");
  $conname=odbc_result($rs,"LastName");
  echo "<tr><td>$compname</td>";
  echo "<td>$conname</td></tr>";
  }
odbc_close($conn);
echo "</table>";
?>

</body>
</html>

Double check your set up in the control panel to make sure everything is correct with MS Access driver and DSN for the database. You will have nothing but issues if something is not set up correctly.

Here are some steps to take: http://www.w3schools.com/PHP/php_db_odbc.asp

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.