Page 1 of 1

PHP doesn't recognize directories

Posted: Thu Aug 03, 2006 9:27 pm
by daedalus__
I have this function (which needs improvement, feel free to comment):

Code: Select all

function CreatePlayer($dj_name)
{
	$base_dir	= 'musicPlayer/';
	$dir_name	= $base_dir.$dj_name.'/';
	
//	echo "Make directory: $dir_name\n";
//	if (mkdir($dir_name))
//	{
//		echo "Directory created: $dir_name\n";
		// See if the base directory exists
		echo "Does $base_dir exist?\n";
		if (is_dir($base_dir))
		{
			echo "Yes\n";
			// Open it
			echo "Try to open it:\n";
			if ($dh = opendir($base_dir))
			{
				echo "Opened\n";
				// If there are files and
				echo "Are there files? Try reading the directory\n";
				while (FALSE !== ($file = readdir($dh)))
				{
					// they are not the current directory, previous directory, and are a file
					if (($file != '.') && ($file != '..'))
					{
						echo "Filename: $file\n";
						if (filetype($file) == 'dir')
						{
							echo "THIS IS A DIRECTORY OH <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> NO\n\n";
						}
						else
						{
							echo "NOT A DIRECTORY\n\n";
						}
						/* Copy them to the new directory
						if (copy($file, $dir_name.$file))
						{
							echo 'Player successfully copied to new DJ\'s directory';
							return 1;
						}
						else
						{
							echo 'Could not copy file: '.$dir_name.$file;
							return 0;
						}*/
					}
				}
			}
			else
			{
				echo 'Could not open directory: '.$base_dir;
				return 0;
			}
		}
		else
		{
			echo 'Directory does not exist: '.$base_dir;
			return 0;
		}
//	}
//	else
//	{
//		echo 'Could not create dir: '.$dir_name;
//		return 0;
//	}
}
For some reason, the directory that is inside of musicPlayer; daedamothersmurfalus gets return as not a file. I do not know what is wrong, I have tried like 87 different things.

Here is the output:

Code: Select all

Does musicPlayer/ exist?
Yes
Try to open it:
Opened
Are there files? Try reading the directory
if they are not directories then print the filenames

Filename: <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>
NOT A DIRECTORY

Filename: player.fla
NOT A DIRECTORY

Filename: player.html
NOT A DIRECTORY

Filename: player.swf
NOT A DIRECTORY

Filename: player.xml
NOT A DIRECTORY

Filename: tylerparker1.mp3

Posted: Thu Aug 03, 2006 9:53 pm
by feyd

Posted: Thu Aug 03, 2006 11:45 pm
by daedalus__
$daedalus == 'noob' != FALSE

:(

Posted: Thu Aug 03, 2006 11:46 pm
by Benjamin
Daedalus- wrote:$daedalus == 'noob' != FALSE
You have an error in your syntax :wink: