Forums: Back End:

 

why is this not working??? (PHP)

first
 

Tha.Riddla why is this not working??? (PHP)

ok, so i'm using craftyminds Flash photo thingy from here and I can get it to work in the same directory that the gallery.php file is in, but not in any other directory....it's driving me bonkers.

This works

<?php
$xml = '<?xml version="1.0"?'.'>';

$filepath = ".";

$handle = opendir($filepath);
while (false != ($file = readdir($handle))) {
$pic = @getimagesize($file);
if($pic != false && $pic[2] == 2){
$xml .= '<img src="'.$file.'" width="'.$pic[0].'" height="'.$pic[1].'" />';
}
}

echo $xml;
closedir($handle);

?>


This does not:
<?php
$xml = '<?xml version="1.0"?'.'>';

$filepath = "test";

$handle = opendir($filepath);
while (false != ($file = readdir($handle))) {
$pic = @getimagesize($file);
if($pic != false && $pic[2] == 2){
$xml .= '<img src="'.$file.'" width="'.$pic[0].'" height="'.$pic[1].'" />';
}
}

echo $xml;
closedir($handle);

?>


neither does
$filepath = "/test";
$filepath = "/test/";
$filepath = "./test";

or anything like that. Am I insane? If I can get this to work, I'm eventually wanting to add a list of folders that get passed via $_GET in the URL string to choose the gallery the user is viewing...baby steps.

 

JimmyTheGent

have you tried

$filepath = "./test/";
or
$filepath = "test/";

Both should work.

 

Tha.Riddla

yes and yes....neither work. I'll try them again in the morning.


I've even tried

$filepath = "." . "test";

and variations like it.

 

JimmyTheGent

What error message are you getting?

 

Tha.Riddla

i'm not getting any php error messages, so i'm wondering if it's a php -> flash issue.

It's confusing because when i just use the root folder the whole thing works fine, images display and stack. but when i try to use a subfolder, i get nothing.

 

DontBogartMe

have you tried viewing the output of your php script in a browser, just to see what it's churning out? Do that and post the output here if you can?

"anything invented before you were 18 has been there forever, anything that turns up before you're 30 is new and exciting, and anything after that is a threat to the world and must be destroyed."

quote
 

DontBogartMe

of course... that 'test' folder does actually exist doesn't it? smile

"anything invented before you were 18 has been there forever, anything that turns up before you're 30 is new and exciting, and anything after that is a threat to the world and must be destroyed."

quote
 

Tha.Riddla

after viewing the output a few times...i figured it out. I was getting output from the root, but nothing from any subdirectory, so I revisited my actual code, and found that i was missing the filepath in my function. Here is my new code:

<?php
$xml = '<?xml version="1.0"?'.'>';

$filepath = "test";

$handle = opendir($filepath);
while (false != ($file = readdir($handle))) {
$pic = @getimagesize($filepath."/".$file);
if($pic != false && $pic[2] == 2){
$xml .= '<img src="'.$filepath."/".$file.'" width="'.$pic[0].'" height="'.$pic[1].'" />';
}
}

echo $xml;
closedir($handle);

?>


I needed to ad the following in bold:
$pic = @getimagesize($filepath."/".$file);
$xml .= '<img src="'.$filepath."/".$file.'" width="'.$pic[0].'" height="'.$pic[1].'" />';

after that, it worked like a charm. I'll post this revised code in craftymind's thread as well. Thanks for the help!

 

DontBogartMe

Originally posted by: Tha.Riddla
after viewing the output a few times...i figured it out.


that's always the first step to take with Flash and XML problems, otherwise you're just working blind.

Glad you sorted it - well done!

"anything invented before you were 18 has been there forever, anything that turns up before you're 30 is new and exciting, and anything after that is a threat to the world and must be destroyed."

quote
 
first
 

Forums: Back End: why is this not working??? (PHP)

 
New Post
 
You must be logged in to post