Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial 新手求助,php循环问题

新手求助,php循环问题

Jun 23, 2016 pm 02:16 PM

代码中的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 文档解析错

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

11 Best PHP URL Shortener Scripts (Free and Premium) 11 Best PHP URL Shortener Scripts (Free and Premium) Mar 03, 2025 am 10:49 AM

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Working with Flash Session Data in Laravel

Introduction to the Instagram API Introduction to the Instagram API Mar 02, 2025 am 09:32 AM

Introduction to the Instagram API

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Simplified HTTP Response Mocking in Laravel Tests

Build a React App With a Laravel Back End: Part 2, React Build a React App With a Laravel Back End: Part 2, React Mar 04, 2025 am 09:33 AM

Build a React App With a Laravel Back End: Part 2, React

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

12 Best PHP Chat Scripts on CodeCanyon

Notifications in Laravel Notifications in Laravel Mar 04, 2025 am 09:22 AM

Notifications in Laravel

See all articles