View Full Version : Why didn't working this code? pls help me :-(

08-22-2009, 12:16 AM
Can somebody explain why this code didn't work for me?


$path = "./images/";

$dir_handle = @opendir($path) or die("Unable to open folder");

while (false !== ($file = readdir($dir_handle))) {

if($file == "index.php")
if($file == ".")
if($file == "..")

echo "<img src='$file' alt='$file'><br />";



So,the problem is:
If I change the value of $path = "./"; instead of $path = "./images/"; it is working,but if I change it from $path = "./"; to $path = "./images/"; i got all the time this message:
"Unable to open folder"

Pls. can somebody explain me the right way to make path changing in PHP and how can I change my path from "images" to "thums" or backward?

Thnx a lot.

08-22-2009, 02:15 AM
$dir_handle = @opendir($path) or die("Unable to open folder");

Rather than suppressing PHP's errors telling you what's wrong, try removing the @ and the or die clause allowing PHP to help you. I suspect that PHP doesn't have permission to access the folder in question, you'll need to CHMOD the correct permissions onto it.

08-22-2009, 02:53 AM
Make sure the directory is readable

08-22-2009, 03:12 AM
Make sure the directory is readable

But first, make sure your post is readable, and then we can be of more help.


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum