note 43947 added to function.odbc-connect
| From: | (Fadi) | Date: | Fri, 09 Jul 2004 17:13:04 +0000 |
| Subject: | note 43947 added to function.odbc-connect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-72926@lists.php.net to get a copy of this message | ||
This is the typical solution with the steps to follow if someone wants to connect MS Access to PHP.
it took me a couple of hours actually till i reached it. i just wanted to ease the hassle for my
colleagues in order not to waste their time as i did. this is the duty of every programmer towards
his/her peers :p
here you are the CAKE :)
<?php
// to have this working:
// 1- u have first to creat ur access database using MS
// Access (i asume u know how to do this). My database
// that i used in my example is called "Questionaire.mdb".
// the table in it is called "Results"
//
// 2- then u have to add this database to ODBC in the
// control panel.
//
// 3- the adition happens by adding "MS Access Driver" to the
// "System DNS" tab in ODBC Data Source Administrator. if
// u have that "MS Access Driver" in "User DNS" tab, then
// u have to delete it.
//
// 4- click on Add in the "System DNS" tab.
//
// 5- choose "MS Access Driver" from the "Creat New
// Database Source" window and click finish.
//
// 6- then the "ODBC MS Access Setup" window will pop-up.
//
// 7- give the driver the name that you want to use in your
// PHP scripting. i used here "MSAccessDriver".
// 8- after this, choose the "Select" button in "ODBC MS
// Access Setup" to set the path of your Access database.
//
// 9-then u r done!!
// this odbc_connect does the connection to the driver i
// created in the ODBC Administrator
$con = odbc_connect('MSAccessDriver','','');
if ($con)
{
echo "odbc connected<br>";
$sql = "select * from Results";
//this function will execute the sql satametn in
//correspondance to the table in the db
$exc = odbc_exec($con,$sql);
}
else
echo "odbc not connected<br>";
if($exc)
{
echo "selection completed<br>";
while($row = odbc_fetch_row($exc) )
echo $row->id."<br>";
}
else
echo "selection failed<br>";
?>
----
Manual Page -- http://www.php.net/manual/en/function.odbc-connect.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43947
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43947&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43947&report=yes
Search -- http://master.php.net/manage/user-notes.php