Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Xml file not being overwritten. WTH? 1

Status
Not open for further replies.

SgtGranite

Programmer
Apr 8, 2009
3
BR
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.
 
Well this is clearly a php question but, as a suggestion, maybe the file is being created on another path, I mean .. is not what you think it is.

Cheers,
Dian
 
Should be related to write permission to the file and/or the containing directory. Ask the corresponding webserver or desktop forum.
 
Where do you find the "save" for fwrite?
 
I solved this problem. It was a permission problem for the path. Thank you.

@RickBeddoe: Yes, that's what fwrite() does, it saves the file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top