2013-06-12 97 views
0

您好我想使用的PHP ODBC和我似乎有一些problems.This是我的代碼:連接到數據庫中warnnings ODBC結果和notjing印刷

<?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\n"); 
    } 
    odbc_close($connect); 
    ?> 

我也mysql安裝ODBC連接器,並將此係統DSN: 數據源名稱:數字圖書館 TCP/IP服務器:localhost端口80 用戶:根 數據庫:數字圖書館

當我運行我的代碼,我得到這個警告,但沒有印刷:

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

我做錯了什麼?

回答

2

現在,您正試圖將64位應用程序與32位ODBC驅動程序一起使用,反之亦然。你應該檢查你在使用什麼PHP應用程序的64位或32位。之後,您必須啓動正確的ODBC管理員。有兩種類型,分別是32 bit64 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.

當您設置了正確的ODBC管理員。您還需要創建系統DSN。如果您在管理員中找不到MS Access驅動程序,則需要爲該體系結構下載一個。

編輯:您可以從here

希望這有助於下載32位。

+0

更高版本的Windows在控制面板/管理工具中同時擁有64位和32位數據源管理員。 –

+0

64位和32位odbc驅動程序可以同時在同一臺服務器上運行嗎?我們有一個Win Server 2008 R2。 – JCm

+0

如果我將另一個ODBC驅動程序(32位版本來滿足我的32位應用程序)添加到現有64位版本的服務器(某些其他應用程序可能使用64位),會不會有問題?它不會造成其他應用程序的confilict?我擔心如果我安裝一個32位版本,它可能會影響服務器上現有的和正在運行的應用程序 – JCm