Home > Backend Development > PHP Tutorial > 新手求助,php循环问题

新手求助,php循环问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 14:16:15
Original
1118 people have browsed it

代码中的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>';
Copy after login


回复讨论(解决方案)

mysql_query("set names utf8;");
明明是adodb,怎么还冒出来个mysql_query?

$rs->Open("select * from mtv_singer",$conn,3,1);
明显应该是:
$rs = $conn->Execute('select * from mtv_singer')吧

mysql_query("set names utf8;");
明明是adodb,怎么还冒出来个mysql_query?

$rs->Open("select * from mtv_singer",$conn,3,1);
明显应该是:
$rs = $conn->Execute('select * from mtv_singer')吧
我$field_2这个字段是数据库中的内容是中文的,加进去就报错了,请问怎么解决,谢谢
chrome:
This page contains the following errors:
error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.
ff:
XML解析错误:文档元素之后的废弃内容 
位置:http://localhost/mtv/singer.php 
行:2,列:1:

你需要输出 utf-8 的 xml 文档,而 Access 根本就没有 utf-8 字符集
如果你不做编码转换,那么就一定会出现 xml 文档解析错

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template