PHP ODBC connect() to Access - 架构不匹配

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9219897/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 06:23:16  来源:igfitidea点击:

PHP ODBC connect() to Access - architecture mismatch

phpms-accessodbc

提问by Alex.Barylski

I have googled for hours now.

我已经用谷歌搜索了几个小时。

I have read countless articles such as: Is there a Windows 7 ODBC driver for Access?

我读过无数文章,例如:是否有用于 Access 的 Windows 7 ODBC 驱动程序?

I have tried using both the ODBC admin - and have managed to successfully add there system DSN for both:

我已经尝试使用 ODBC 管理员 - 并成功地为两者添加了系统 DSN:

  • Microsoft Access Database
  • Microsoft do Access Database
  • 微软访问数据库
  • 微软做 Access 数据库

When I attempt to connect to Access DB stored locally:

当我尝试连接到本地存储的 Access DB 时:

odbc_connect('Aquarius2', '', '');

I get the following error(s):

我收到以下错误:

odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application, SQL state IM014 in SQLConnect in C:\export\export.php on line 3

odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] 指定的 DSN 包含驱动程序和应用程序之间的架构不匹配,SQL 状态 IM014 in SQLConnect in C:\export\export.php on line 3

Simple script tried installing the latest access drivers - Aquarius2is the name of my DSN still fails.

简单的脚本尝试安装最新的访问驱动程序 -Aquarius2我的 DSN 的名称仍然失败。

I'm out of ideas - what am I missing?

我没有想法 - 我错过了什么?

Regards, Alex

问候,亚历克斯

回答by bohica

You are attempting to use a 64 bit application with a 32 bit ODBC driver or vice versa. Look at ODBC on 64-bit Windows Platforms.

您正在尝试将 64 位应用程序与 32 位 ODBC 驱动程序一起使用,反之亦然。查看64 位 Windows 平台上的ODBC

You need to determine whether your PHP application is 64 bit or 32 bit first.

您需要首先确定您的 PHP 应用程序是 64 位还是 32 位。

Then once you've ascertained that you need to start the correct ODBC administrator - there are 2 of them, one for 32 bit and one for 64 bit. The 64 bit ODBC administrator is in Adminstrative tools, control panel and the 32 bit one is in %windir\syswow64\odbcad32.exe.

然后,一旦您确定需要启动正确的 ODBC 管理员 - 其中有 2 个,一个用于 32 位,一个用于 64 位。64 位 ODBC 管理员位于管理工具、控制面板中,而 32 位管理员位于%windir\syswow64\odbcad32.exe.

Once you've matched your application architecture to the right ODBC administrator, you need to create the system DSN. If you cannot find the MS Access driver in the administrator, you'll need to download one for that architecture. I'm not sure if there is a 64 bit MS Access ODBC driver; if there isn't, you'll have to change your application architecture.

将应用程序体系结构与正确的 ODBC 管理员匹配后,您需要创建系统 DSN。如果在管理员中找不到 MS Access 驱动程序,则需要为该架构下载一个。我不确定是否有 64 位 MS Access ODBC 驱动程序;如果没有,您将不得不更改您的应用程序架构。

The article I referencedhas more information.

我参考的文章有更多信息。

回答by sagesmondo

One other note: if you installed the 64-bit WampServer, it installs 64-bit everything - Apache, MySQL, PHP. If you want a 32-bit PHP to have around, go to the PHP downloads pageand choose one of the 'win32' releases. And don't forget to change your php path when you run your application! This plus setting up the 32-bit ODBC administrator - %windir\syswow64\odbcad32.exe- and you should be good to go.

另一个注意事项:如果您安装了 64 位 WampServer,它会安装 64 位所有内容 - Apache、MySQL、PHP。如果您想要 32 位 PHP,请转到PHP 下载页面并选择“win32”版本之一。并且不要忘记在运行应用程序时更改 php 路径!这加上设置 32 位 ODBC 管理员 - %windir\syswow64\odbcad32.exe- 你应该很高兴。