Topic: Dynamic gallery.xml output in php trouble

Hi Simpleviewers,

I'm generating the gallery.xml dynamically through PHP.

Here's my desired output:

<?xml version="1.0" encoding="UTF-8"?>
<simpleviewerGallery maxImageWidth="480" maxImageHeight="480" textColor="0x000000" frameColor="0x000000" frameWidth="10" stagePadding="20" thumbnailColumns="3" thumbnailRows="3" navPosition="right" title="Photos" enableRightClickOpen="true" backgroundImagePath="" thumbPath="users/ejustice2/" imagePath="users/ejustice2/">
<image>
<filename>house-selling-1.jpg</filename>
<caption>My photo</caption>
</image>
</simpleviewerGallery>

The info in the <image> tag is displaying GREAT but  I want the thumbpath and imagepath to be dynamic.  Here's my php code:

function makeXML($pid, $oid){
    $getphotos = mysql_query("SELECT * FROM postings_photos WHERE post_id = '$pid' ORDER BY isPrimary DESC");
    $userinfo = mysql_fetch_assoc(mysql_query("SELECT username FROM users WHERE uid = '$oid'"));
    $username = $userinfo['username'];
    $directory = "users/".$username."/";
;
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml .= '<simpleviewerGallery maxImageWidth="480" maxImageHeight="480" textColor="0x000000" frameColor="0x000000" frameWidth="10" stagePadding="20" thumbnailColumns="3" thumbnailRows="3" navPosition="right" title="Photos" enableRightClickOpen="true" backgroundImagePath="" thumbPath="users/'.$username.'/" imagePath="users/'.$username.'/" >';
    while($row = mysql_fetch_assoc($getphotos)) { 
        $xml .= '<image><filename>'.$row['filename'].'</filename><caption>'.$row['description'].'</caption></image>';
    } //while
    $xml .= '</simpleviewerGallery>';
return $xml;
}

$xmlCode = makeXML($pid, $oid);
header('Content-Type: application/xml; charset=UTF-8');
header('Content-Disposition: inline; filename="gallery.xml"');
header("Content-Length: ".strlen($xmlCode ));
header('Expires: 0');
header('Pragma: cache');
header('Cache-Control: private'); 
echo $xmlCode;

This code will show white X's, but when I view the XML that PHP is generating, it looks EXACTLY like the desired output above.  When I hard-code the imagepath and thumbpath, it works.  When it's output by PHP it doesn't work but again, when the XML is viewed, it shows the correct path.

Anyone know why?

Thanks,

Erin

Re: Dynamic gallery.xml output in php trouble

Check the pathname letter cases match exactly.

Felix Turner
SimpleViewer Support Team.