0

PC に Sage Line 50 ODBC ドライバーをセットアップし、同じマシンで XAMPP php サーバーを使用して、PHP で sage データベースにクエリを実行しています。

以下は、Sales Ledger テーブルを調べるための基本的なコードです。

<?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� 
) 

なぜこれが起こっているのか、そしておそらくこれを行うためのより良い方法があるかどうかについて、誰かが提案を提供できますか.

どんな考えや経験でも大歓迎です。

よろしく

ジェームズ

4

2 に答える 2