Connecting to MS Access DB
Posted: Tue Feb 21, 2006 5:19 am
Hi
I am trying to create a connection to my Acess DB warehouse which has 1 table Users and Autonumber username password as fields ...
This is the code i wrote .. but i feel that i am missing something can someone show me the right path please
I am trying to create a connection to my Acess DB warehouse which has 1 table Users and Autonumber username password as fields ...
This is the code i wrote .. but i feel that i am missing something can someone show me the right path please
Code: Select all
<?
$conn=odbc_connect('warehouse','','');
if (!$conn)
{exit("Connection Failed: " . $conn);}
$sql="SELECT username FROM Users";
$sql="SELECT password FROM Users";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");}
echo "<table><tr>";
echo "<th>username</th>";
echo "<th>password</th></tr>";
while (odbc_fetch_row($rs))
{
$username=odbc_result($rs,"username");
$password=odbc_result($rs,"password");
echo "<tr><td>$username</td>";
echo "<td>$password</td></tr>";
}
odbc_close($conn);
echo "</table>";
?>