Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 21st, 2006, 6:07 AM   #1
Heba
Newbie
 
Join Date: Feb 2006
Posts: 18
Rep Power: 0 Heba is on a distinguished road
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>";
?>
Heba is offline   Reply With Quote
Old Feb 21st, 2006, 9:05 AM   #2
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,473
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:31 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC