Hi all,
I’m trying to create an xml file using php, and use it to get data from flash.
This is the code I’ve written so far and it doesn’t create an xml in my current directory. Could you tell me what am I doing wrong here?
php file:
[CODE]mysql_select_db($database_website_news, $website_news);
$query_all_news = “SELECT * FROM news”;
$all_news = mysql_query($query_all_news, $website_news) or die(mysql_error());
$row_all_news = mysql_fetch_assoc($all_news);
$totalRows_all_news = mysql_num_rows($all_news);
$_xml = “<?xml version=”1.0″ encoding=”utf-8″?>n<!DOCTYPE data[n
<!ELEMENT title(comments, image)>n
<!ATTLIST title name CDATA #REQUIRED>n
<!ELEMENT text (#PCDATA)>n
]>n
<data>n”;
do {
$_xml .= ‘<title name=”‘.$row_all_news[‘title’].'”>n’;
$_xml .= ‘<text>’.$row_all_news[‘text’].'</text>n’;
$_xml .= ‘</title>’;
} while ($row_all_news = mysql_fetch_assoc($all_news));
$_xml .= “</data>”;
//create the xml file and insert into the specific album’s folder
$file = ‘new.xml’;
$fh = fopen($file, ‘w’) or die(“can’t open file”);
fwrite($fh, $_xml);
fclose($fh);