Please Check my Code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Blyant
Forum Newbie
Posts: 12
Joined: Fri Sep 30, 2005 8:14 am

Please Check my Code

Post by Blyant »

I'm currently using this piece of PHP to print out an XML document to be used i flash it works very well:

Code: Select all

<?php
echo "<?xml version=\"1.0\" encoding =\"ISO-8859-1\" ?>\n";
echo "<images>\n";
if ($handle = opendir('./portfolio')) {
	$files_array = array();
	// Gather files in array
	while (false !== ($file = readdir($handle))) {
		if ($file !== "." && $file !== "..") {
			list($width, $height) = getimagesize("portfolio/".$file);
			$mtime = filemtime("portfolio/" . "$file");
			array_push($files_array, array(
				'mtime' => $mtime,
				'path' =>  "portfolio/" . "$file",
				'width' => $width,
				'height' => $height
			));
		}
	}
	// Sort array
	rsort($files_array);
	// Print XML
	for ($i=0;$i<count($files_array);$i++) {
		echo "<myImage myPath=\"" . $files_array[$i]['path'] ."\" myWidth=\"" . $files_array[$i]['width'] ."\" myHeight=\"" . $files_array[$i]['height'] ."\" />\n";
	}
	closedir($handle);
}
echo "</images>\n"
?>
However I want to start to post a variable from flash that defines which directory to open (currently defined as "portfolio"). I'm trying the code below to define the directory as a variable without success, I'm not sure if the problem is here in the PHP or in my Actionscript. If there are problems here could somene be kind enough to point them out to me:

Code: Select all

....
$myFileName = $_POST["myFileName"];
if ($handle = opendir('./$myFileName'))
.....
sheila
Forum Commoner
Posts: 98
Joined: Mon Sep 05, 2005 9:52 pm
Location: Texas

Post by sheila »

You need double quotes when you use $myFileName

Code: Select all

$myFileName = $_POST["myFileName"];
if ($handle = opendir("./$myFileName"))
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

I'd make sure first the variables are arriving in $_POST.

Code: Select all

vardump($_POST);
I didn't know you could use XML to import variables into Flash. I've only used the sendAndRecieve object and query strings.

Good luck.
Blyant
Forum Newbie
Posts: 12
Joined: Fri Sep 30, 2005 8:14 am

Post by Blyant »

Thanks for the pointers, it seems as though the problem is in my actionscript. I see the problem now, but is above my actionscript ability. I'll have to get over to the Macromeida forum and hope someone takes pitty on me.
I didn't know you could use XML to import variables into Flash. I've only used the sendAndRecieve object and query strings.
Apparently Flash loves a bit of XML.
Post Reply