douyue7536 2013-06-12 17:46
浏览 320
已采纳

使用ODBC连接到数据库会导致警告并且不会打印任何内容

I am trying to use ODBC with php and I seem to be having some problems. This is my code:

<?php
    $connect = odbc_connect("digitallibrary", "root", "");
    $sql = "SELECT name FROM books";
    $result = odbc_exec($connect, $sql);
    echo $result;

    while (odbc_fetch_row($result)) {
        $name = odbc_result($result, "name");
        print("$name
");
    }
    odbc_close($connect);
    ?>

I have also installed mysql odbc connector and added this system DSN: Datasource Name : digitallibrary TCP/IP Server: localhost Port 80 user: root database:digitallibrary

When I run my code I get this warnings but nothing printed:

Warning: 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 E:\Program Files\xampp\htdocs\DigitalLibrary\index.php on line 9

Warning: odbc_exec() expects parameter 1 to be resource, boolean given in E:\Program Files\xampp\htdocs\DigitalLibrary\index.php on line 11

Warning: odbc_fetch_row() expects parameter 1 to be resource, null given in E:\Program Files\xampp\htdocs\DigitalLibrary\index.php on line 14

Warning: odbc_close() expects parameter 1 to be resource, boolean given in E:\Program Files\xampp\htdocs\DigitalLibrary\index.php on line 18

what am I doing wrong?

  • 写回答

1条回答 默认 最新

  • dongliang1941 2013-06-12 17:53
    关注

    Now, You are attempting to use a 64 bit application with a 32 bit ODBC driver or vice versa. You should check that what are you using the PHP application 64 bit or 32 bit. After that you have to start the correct ODBC administrator. There are 2 types which are 32 bit and and 64 bit.

    If you are using 64 bit ODBC administrator: It is in Adminstrative tools, control panel

    If you are using 32 bit ODBC administrator: You should go into the path %windir\syswow64\odbcad32.exe.

    When you have set the right ODBC administrator. You will also 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.

    EDIT : you can download the 32 bit from here

    Hope this helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题的应用
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办