PDA

View Full Version : connect to database


andrewsheldon98
12-11-2002, 09:27 AM
i have created a table in an access database (test.mdb).

how do i connect to this database and show the contents of the table called testtable in test.mdb

firepages
12-11-2002, 05:17 PM
Hi you first have to set up a data source name (Control panel > adminstrative options > ODBC)

make sure you create a system DSN NOT a user DSN else it wont work (note also that lowercase dsn names seem to have less issues with PHP ???)




<?
$dsn="test_db";//dsn for test.mdb//
$conn = odbc_connect($dsn, "", "")or die(odbc_errormsg());
$yaks=odbc_exec($conn,"SELECT * FROM testtable")or die(odbc_errormsg());
odbc_result_all($yaks);
?>