hello, a struggling newbie here
What i'm trying to do is generate a xml file with additional text specified with'in the tag <gallery>, but when i enter the text into the tag it fails to write the xml file, i guess it's probably a syntax error on my part.
here's my code;
<?php
$DBhost = "localhost"; // Database Server
$DBuser = "DBuser"; // Database User
$DBpass = "DBpass"; // Database Pass
$DBName = "quote"; // Database Name
$table = "gallery"; // Database Table
// Connect to mySQL Server
$DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error in Gallery Application: " . mysql_error());
// Select mySQL Database
mysql_select_db($DBName, $DBConn) or die("Error in Gallery Application: " . mysql_error());
$query = "SELECT * FROM $table";
$dbresult = mysql_query($query, $DBConn);
echo "Connected";
function Display($Value) {
return htmlspecialchars(addslashes($Value));
}
$xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n\n";
$xml .= "<gallery
galleryname="Gallery name"
layout="3"
preferredstage="0"
stagewidth="670"
stageheight="440"
popuplink="1"
popuplinktype="2"
popuplinktext="Click here to view larger version"
\n\n";
while ($dat = mysql_fetch_array($dbresult)) {
$xml .= "\t<image thumb=\"".Display($dat['thumb'])."\">\n";
$xml .= "\t<description>".Display($dat['info'])."</description>\n";
$xml .= "\t<imageurl>".Display($dat['image'])."</imageurl>\t\n";
$xml .= "\t</image>\n\n";
}
$xml .= '</gallery>';
$Fichier = fopen('gallery.xml', 'w+');
fputs($Fichier, $xml);
fclose($Fichier);
?>
and ideally it would write the following if it was working properly;
<gallery
galleryname="Gallery name"
layout="3"
preferredstage="0"
stagewidth="670"
stageheight="440"
popuplink="1"
popuplinktype="2"
popuplinktext="Click here to view larger version"
<image thumb="images/image-thumb.jpg"</image>
<captiontext>image 1 sample text</captiontext>
<imageurl>images/image.jpg</imageurl>
</gallery>
I'm really stuck, So please help! thank you.