2015-07-21 34 views
0

我在PC上設置了Sage Line 50 ODBC驅動程序,並且在同一臺機器上使用XAMPP php服務器來查詢使用PHP的sage數據庫。Sage 50 ODBC PHP編碼問題

下面是一些基本的代碼來詢問銷售臺賬表:

<?php 
error_reporting(E_ERROR); 

//attempt to connect to Sage Line 50 via the system DSN which is on the Sage Server 
echo("Trying to connect to Sage<hr>"); 

if(isset($_REQUEST['account_ref']) && $_REQUEST['account_ref'] != "") { 
$account_ref = $_REQUEST['account_ref']; 

$odbc['dsn'] = "SAGE50"; 
$odbc['user'] = "manager"; 
$odbc['pass'] = "brand"; 

$conn = odbc_connect($odbc['dsn'], $odbc['user'], $odbc['pass']); 
if (!$conn) { 
    die("Error connecting to the ODBC database: " . odbc_errormsg()); 
} else { 
    $obj = array(); 
    echo("Connected<br>"); 
    $query = odbc_exec($conn, "SELECT * FROM SALES_LEDGER where ACCOUNT_REF = '{$account_ref}'"); 

    while ($row = odbc_fetch_array($query)) { 
     print_r($row); 
    } 
} 
} else { 
    return false; 
} 

現在,查詢的實際工作和檢索數據。然而,它大部分看起來都是垃圾,並且具有奇怪的字符而不是值。

例如:

Array ( 
[�������] => [] => 
[0] => 0 
[Defaul] => Defaul 
[Open] => Open 
[T1] => T1 
[4000] => 4000 
[1] => 1 
[GB] => GB 
[0.00] => 0.00 
[30] => 30 
[2009-10-22] => 2009-10-22 
[Good] => Good 
[201x��201] => 201x��201 
[201���0�] => 201���0� 
) 

任何人都可以提供關於爲什麼這可能發生的任何建議,也許,如果有這樣做的更好的方法。

任何想法或經驗都會受到歡迎。

問候

詹姆斯

回答

0

我遇到了一模一樣的問題,因爲這不是很久以前。我無法告訴你是什麼原因造成的,但我可以告訴你,將Wamp替換爲Wamp完全可以解決它。