Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/08/2004, 09:21
angaturama
 
Fecha de Ingreso: abril-2004
Ubicación: México
Mensajes: 10
Antigüedad: 20 años
Puntos: 0
xml generado por php

Hola buen dia.

Tengo este codigo php que me genera un xml a partir de una base de datos mysql, el único problema qué tengo es que al escribirlo a el xml, no me toma los acentos ni las ñ. alguien me podría orientar a resolver este problema.

Saludos
David

<?php
$connection = mysql_connect("localhost","root", "")
or die ("could not connect to database");
$db = mysql_select_db("gtcontadores",$connection)
or die ("Couldn't select database.");
$result = mysql_query("select * from flash_news",$connection)
or die ("invalid query");
$num = mysql_num_rows($result);
if ($num != 0) {
$file= fopen("results.xml", "w");
$_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
$_xml .="<mgcontadores>\r\n";
while ($row = mysql_fetch_array($result)) {
if ($row["title"]) {
$_xml .="\t<page id=\"" . $row["id"] . "\" fecha=\"" . $row["fecha"] . "\" title=\"" . $row["title"] . "\" link=\"".$row[4] . "\">\r\n";
$_xml .="\t\t<body><![CDATA[" . $row["body"] . "]]></body>\r\n";
$_xml .="\t</page>\r\n";
} else {
$_xml .="\t<page title=\"Nothing Returned\">\r\n";
$_xml .="\t</page>\r\n";
} }
$_xml .="</mgcontadores>";
fwrite($file, $_xml);
fclose($file);
echo "XML has been written. <a href=\"results.xml\">View the XML.</a>";
header("Location: admin.php");
} else {
echo "No Records found"
}
?>

Última edición por angaturama; 30/08/2004 a las 09:33 Razón: error en el titulo