An error occurred while coding the XML file in php.

Source: Internet
Author: User
Tags php write
Php writes an XML file encoding error. I have a video table. The data structure is as follows: I use the following program to read the table file and generate the XML file: include ("conn. php "); include (" crop. php "); $ xmlFile & nbsp ;=& nbsp;" 123.xml"; $ dom & nbs php write XML file encoding error, please answer
I have a video table with the following data structure:


I use the following program to read table files and generate XML files:

Include ("conn. php ");
Include ("crop. php ");

$ XmlFile = "123.xml ";
$ Dom = new DomDocument ('1. 0', 'utf-8 ');
$ Dom-> formatOutput = true;
$ Thumbnails = $ dom-> createElement ("thumbnails ");
Mysql_select_db ('hdm0910283 _ db', $ lnk) or die ('Can \'t use hdm0910283_db:'. mysql_error ());
Mysql_query ("set names UTF-8 ");
$ SQL = "select * from video ";
$ Query = mysql_query ($ SQL );
While ($ row = mysql_fetch_array ($ query )){
// Cut youku
$ Imageurl = "../workshow/images/". $ row [imgname];
Cutphoto ("$ imageurl", "$ imageurl", 200,113 );
$ Dom-> appendChild ($ thumbnails );
$ Thumbnail = $ dom-> createElement ("thumbnail ");
$ Thumbnail-> setAttribute ('filename', $ row [imgname]);
$ Thumbnail-> setAttribute ('label', $ row [title]);
$ Thumbnail-> setAttribute ('URL', $ row [url]);
$ Thumbnails-> appendChild ($ thumbnail );
}
$ Dom-> save ($ xmlFile );


The following error is prompted during running:
Arning: DOMElement: setAttribute () [domelement. setattribute]: string is not in UTF-8 in D: \ AppServ \ www \ rj \ control \ xml_do.php on line 20

Warning: DOMDocument: save () [domdocument. save]: output conversion failed due to conv error, bytes 0xCA 0xD3 0xC6 0xB5 in D: \ AppServ \ www \ rj \ control \ xml_do.php on line 24

I have tested data insertion and reading in tables. please help me solve this problem. XML
------ Solution --------------------
Mysql_query ("set names utf8 ");
UTF-8 is invalid.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.