I used flex+php+mysql to read data and there was a problem! How can I change the writing? ?
This is the code for BookDAO.php:
<?php
$link = mysql_connect(“localhost”,”***”,”***”);
Mysql_select_db(“book”);
mysql_query(“SET NAMES ‘utf8’ “);
/*Return books in XML format*/
$sql = ‘SELECT * FROM books’;
$result = mysql_query($sql);
echo “”;
echo “\n”;
while($row = mysql_fetch_array($result)){
echo “” .$row[“id”].””;
echo “” .$row[“author”]. “”;
echo “\n”;
echo “” .$row[“genre”]. “\n”;
echo “” .$row[“price”]. “\n”;
echo “” .$row[“publish_date”]. “\n”;
echo “” .$row[“description”]. “\n”;
}
echo “\n”;
Mysql_close($link);
?>
The result displayed in mxml is: Since I can’t put a picture, I simply counted the results:
Hello!
This is the content of the data displayed by the datagrid. The auhtor tag is also displayed on the page, instead of just displaying the content “Hello!” . . .
Looking for a way to write it?
——Solution——————–
htmlspecialchars() Put your XML string in it and print it out. This is because you did not specify the content-type with the Header.
You can directly header(“Content-Type:xml”);, the code behind remains unchanged, and the browser can still print out tagged XML.