2

我想从linux机器(centos 6.10)访问windows机器(windows server 2003)中的mdb文件

我正在使用 mdbtools 和 unixodbc

到目前为止我做了什么

odbc.ini
[mydatabase]
Driver = MDBTools
Description = Microsoft Access Try DB
Servername = localhost
Database =/mnt/example.mdb
UserName =Admin
Password =
port = 5432

odbcinst.ini
[MDBTools]
Description = MDBTools Driver
Driver64 = /usr/lib64/libmdbodbc.so.0
Setup64  = /usr/lib64/libmdbodbc.so.0
FileUsage   = 1
UsageCount  = 1

我在终端中使用 isql 检查连接

isql -v mydatabase

它返回已连接我可以使用这样的查询成功查询数据库

select * from units

现在我想使用 php 连接访问数据库

test4.php
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);

$myDB = odbc_connect("mydatabase","Admin","");

$query = "select * from units";
$result = odbc_exec($myDB, $query);
$report = odbc_fetch_row($result);
echo odbc_result($result, 1);

odbc_close($myDB);

?>

我收到了这个错误

Warning: odbc_connect(): SQL error: Failed to fetch error message, SQL state HY000 in SQLConnect in /var/www/test/test4.php on line 6

Warning: odbc_exec() expects parameter 1 to be resource, boolean given in /var/www/test/test4.php on line 11

Warning: odbc_fetch_row() expects parameter 1 to be resource, null given in /var/www/test/test4.php on line 12

Warning: odbc_result() expects parameter 1 to be resource, null given in /var/www/test/test4.php on line 13

Warning: odbc_close() expects parameter 1 to be resource, boolean given in /var/www/test/test4.php on line 15

我目前正在使用

PHP Version 7.2.28
mySQL Version   5.7.29
4

0 回答 0