SgtGranite
Programmer
Hello there, everybody!
Dudes, I'm trying to overwrite a xml file using php.
The problem is: the file isn't being overwritten.
Also, if I delete the xml, it's not gonna be created.
Here's the code, take a look:
<code>
function xml(){
$xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\r\n";
$xml .= "<noticia>\r\n";
$sel_noticia = mysql_query("SELECT * FROM noticia WHERE status_noticia='a' ORDER BY data_noticia DESC");
while($row_noticia=mysql_fetch_array($sel_noticia)){
$xml .= "<item>\r\n";
$xml .= "<titulo>\r\n";
$xml .= "<![CDATA[".utf8_encode($row_noticia['titulo_noticia'])."]]>\r\n";
$xml .= "</titulo>\r\n";
$xml .= "<texto>\r\n";
$xml .= "<![CDATA[".utf8_encode($row_noticia['materia_noticia'])."]]>\r\n";
$xml .= "</texto>\r\n";
$xml .= "<link>\r\n";
$xml .= "<![CDATA["."ler_noticia.php?id_noticia=".$row_noticia['id_noticia']."]]>\r\n";
$xml .= "</link>\r\n";
$xml .= "</item>\r\n";
}
$xml .= "</noticia>\r\n";
$open = fopen("../../swf/noticia.xml","w");
fwrite($open,$xml);
fclose($open);
}
</code>
Do you have any idea of why this is happening?
Any help will be appreciated.
Thank you.
Dudes, I'm trying to overwrite a xml file using php.
The problem is: the file isn't being overwritten.
Also, if I delete the xml, it's not gonna be created.
Here's the code, take a look:
<code>
function xml(){
$xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\r\n";
$xml .= "<noticia>\r\n";
$sel_noticia = mysql_query("SELECT * FROM noticia WHERE status_noticia='a' ORDER BY data_noticia DESC");
while($row_noticia=mysql_fetch_array($sel_noticia)){
$xml .= "<item>\r\n";
$xml .= "<titulo>\r\n";
$xml .= "<![CDATA[".utf8_encode($row_noticia['titulo_noticia'])."]]>\r\n";
$xml .= "</titulo>\r\n";
$xml .= "<texto>\r\n";
$xml .= "<![CDATA[".utf8_encode($row_noticia['materia_noticia'])."]]>\r\n";
$xml .= "</texto>\r\n";
$xml .= "<link>\r\n";
$xml .= "<![CDATA["."ler_noticia.php?id_noticia=".$row_noticia['id_noticia']."]]>\r\n";
$xml .= "</link>\r\n";
$xml .= "</item>\r\n";
}
$xml .= "</noticia>\r\n";
$open = fopen("../../swf/noticia.xml","w");
fwrite($open,$xml);
fclose($open);
}
</code>
Do you have any idea of why this is happening?
Any help will be appreciated.
Thank you.