I am trying to connect php server to ms access database and i have tried everything still i am not able to connect.
Here is my code
<?php
$conn=odbc_connect('testdb','','');
//$conn=odbc_connect("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=C:\wamp\www\test\testdb.accdb", '', '');
if (!$conn) {
exit("Connection Failed: " . $conn);
}
$sql="SELECT * FROM testdb";
$rs[]=odbc_exec($conn,$sql);
if (!$rs) {
exit("Error in SQL");
}
while (odbc_fetch_row($rs)) //<-------line 14
{
$json_output[] = odbc_result($rs, "test");
print(json_encode($json_output));
}
odbc_close($conn);
?>
If i use
$conn=odbc_connect('testdb','','');
then i get following error
Warning: odbc_fetch_row() expects parameter 1 to be resource, array given in C:\wamp\www\test\new 1.php on line 14
if I use
$conn=odbc_connect("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=C:\wamp\www\test\testdb.accdb", '', '');
then i get below line as error.
Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in C:\wamp\www\test\new 1.php on line 3
I've edited my php.ini file to include the odbc extension
;extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
extension=php_pdo_odbc.dll <--- here
;extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
Also i have have downloaded and installed Microsoft Access Database Engine 2010 Redistributable from this link.
Also i did try everything that is shown in this video.
I have also done exactly that is written in the accepted answer in this link and i am running 64-bit WampServer Version 2.4 on windows 7 64 bit and also have 64 bit microsoft office.
Sorry for my bad english and i am new to both php and connecting to ms access. I have done connecting to mysql but never to access.