我已经在我的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�
)
谁能提供任何建议,为什么会发生这种情况,也许是否有更好的方法做到这一点。
欢迎有任何想法或经验。
对
詹姆斯我在不久之前遇到了完全相同的问题。我不能告诉你原因是什么,但我可以告诉你,用Xampp代替Wamp完全解决了这个问题。
使用到(utf8_encode,行美元);