Hi guys, i am having trouble trying to test a query (from ms access northwind db) on my local host, I have setup the ODBC connection as follows. After setting up the ODBC i saved the following code in a HTML file. Have I missed out anything else. I am not to sure as I am completley new to this, i just downloaded xampp on my windows computer a few days back. Thanks alot for your help.
Open the Administrative Tools icon in your Control Panel.
Double-click on the Data Sources (ODBC) icon inside.
Choose the System DSN tab.
Click on Add in the System DSN tab.
Select the Microsoft Access Driver. Click Finish.
In the next screen, click Select to locate the database.
Give the database a Data Source Name (DSN).
Click OK.
<html>
<body>
<?php
$conn=odbc_connect('northwind','','');
if (!$conn)
{exit("Connection Failed: " . $conn);}
$sql="SELECT * FROM customers";
$rs=odbc_exec($conn,$sql);
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,"CompanyName");
$conname=odbc_result($rs,"ContactName");
echo "<tr><td>$compname</td>";
echo "<td>$conname</td></tr>";
}
odbc_close($conn);
echo "</table>";
?>
</body>
</html>
PHP MS ACCESS ODBC PROBLEM
Moderator: General Moderators
-
php_new_guy_09
- Forum Newbie
- Posts: 12
- Joined: Fri Sep 04, 2009 3:21 pm
-
php_new_guy_09
- Forum Newbie
- Posts: 12
- Joined: Fri Sep 04, 2009 3:21 pm
Re: PHP MS ACCESS ODBC PROBLEM
Oh yeah, i forgot to say, when i refresh the browser all i get is a blank page?