代码中的while不循环,只能输出一行结果。
还有数据库里有中文的话,运行的时候会报错。
求指教!
header("Content-type:text/xml;charset=utf-8");
$conn = new com("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("syec_mtv.mdb");
$conn->Open($connstr);
mysql_query("set names utf8;");
$rs = new com("ADODB.RecordSet");
$rs->Open("select * from mtv_singer",$conn,3,1);
echo '<?xml version="1.0" encoding="utf-8" ?>';
echo '<veryhdmtvsinger>';
echo '<pageinfo recordcount="2000" pagecount="48" pagesize="40" pageindex="1"/>';
echo '<mtvsingerlist>';
while(!$rs->eof){
$field_0=$rs->Fields(0);
$field_1=$rs->Fields(1);
$field_2=$rs->Fields(2);
$field_3=$rs->Fields(3);
$field_4=$rs->Fields(4);
$field_5=$rs->Fields(5);
$field_6=$rs->Fields(6);
echo "<mtv singerid='$field_0' singercid='$field_1' singer='$field_2' singersex='$field_3' singerarea='$field_4' singerimg='http://192.168.252.66/$field_5' singersid='http://192.168.253.34:103?sid=$field_6' />";
$rs->MoveNext();
}
echo '</mtvsingerlist>';
echo '</veryhdmtvsinger>';
------解决方案--------------------
mysql_query("set names utf8;");
明明是adodb,怎么还冒出来个mysql_query?
$rs->Open("select * from mtv_singer",$conn,3,1);
明显应该是:
$rs = $conn->Execute('select * from mtv_singer')吧
------解决方案--------------------
你需要输出 utf-8 的 xml 文档,而 Access 根本就没有 utf-8 字符集
如果你不做编码转换,那么就一定会出现 xml 文档解析错