![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2006
Posts: 18
Rep Power: 0
![]() |
connecting to MS Accress
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 <?
$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>";
?> |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() ![]() |
The code you wrote? Nah.. the code you -modified- (http://www.w3schools.com/php/php_db_odbc.asp)
![]() One thing I noticed is that you are overwriting your $sql variable right after you define it. If you only have the username and password as fields in the table, use this instead: SELECT * FROM Users; What errors are you getting when attempting to run this code?
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|