PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Dark_AngeL
Forum Commoner
Posts: 39 Joined: Tue Feb 21, 2006 5:16 am
Post
by Dark_AngeL » 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
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>";
?>
Maugrim_The_Reaper
DevNet Master
Posts: 2704 Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland
Post
by Maugrim_The_Reaper » Tue Feb 21, 2006 5:32 am
http://php.mirrors.esat.net/manual/en/f ... onnect.php
You need to have either a DSN for the Access data file, or else use the path to the file on your system to create a DSN-less connection. For example:
Code: Select all
odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=
C:\Access_Files\_database\dbname.mdb", "", "")
Edit: The above is all one line - i broke it in 2 since the forum's PHP divs are not adding a side scoller....
I'm not sure whether the filesystem \ characters should \\ instead - but try it out with the path to your own access file... This is for a DSN-less connection (no ODBC setup required). You can run a google search for more complex examples using Access.
Dark_AngeL
Forum Commoner
Posts: 39 Joined: Tue Feb 21, 2006 5:16 am
Post
by Dark_AngeL » Tue Feb 21, 2006 5:51 am
Thank you
But when i did so and clicked on submit i got this page instead of going to the menu page!
The page cannot be displayed
The page you are looking for cannot be displayed because the page address is incorrect.
--------------------------------------------------------------------------------
Please try the following:
If you typed the page address in the Address bar, check that it is entered correctly.
Open the localhost home page and then look for links to the information you want.
HTTP 405 - Resource not allowed
Internet Information Services
--------------------------------------------------------------------------------
Technical Information (for support personnel)
More information:
Microsoft Support