FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Open 2 Directorys at Once.





cr3ativ3
Ok I am making a sorta of simple forum that I am going to submit as a tutorial on these forums but I can't figure out how two open to directory's at the same time so that two content variables will work in one echo see my code for what I meen:

Code:

<?php
// path to the folder listed - can be full path
//$path = "/var/www/html/";
//or relative path
$path = "Category";

// Open the folder for display
$dir_handle = @opendir($path) or exit("Unable to open $path");
// Loop through the files
while ($folder = readdir($dir_handle)) {
    // do not display current file
   if($folder === ".")
    continue;
   if($folder === "..")
   continue;
    // Display file links

$path1 = "Category/$file"

$dir_handle1 = @opendir($path1) or exit("Unable to open $path1");

while {$folder1 = readdir($dir_handle1)) {
    // do not display current file
   if($folder1 === ".")
    continue;
   if($folder1 === "..")
   continue;

echo "<table width=\"98%\" border=\"0\"><tr><td height=\"24\" background=\"Images/top1.PNG\" align=\"center\" style=\"border:1px #000000 solid\"><div align=\"center\"><font face=\"Arial, Helvetica, sans-serif\" ><b>$folder</b></font></div></td></tr></table><br>$folder1<br>";
)
}
// Close directory
closedir($dir_handle1);
closedir($dir_handle);



?>


So ya if you anything about php you should what I am trying to accomplish here.

But I get this error message when I run the script and I know why but I can't figure out how to fix it so it works the way I intended.

Quote:

Parse error: syntax error, unexpected T_VARIABLE in /home/cr3ativ3/domains/oyoystudios.frih.net/public_html/Forum/ftemplate.php on line 20


Thanks.
Antoine_935
you only missed a ';' after an instruction
Code:
$path1 = "Category/$file"

Add one Wink

But care:
Where is $file defined ?
You have to define it yourself, explicitly, cause users can use it to read any directory within your website... by simply adding "&file=../my/path" in their URL
cr3ativ3
Lol, ya php is strict when it comes to that anyways now I get this errer:

Quote:

Parse error: syntax error, unexpected '{', expecting '(' in /home/cr3ativ3/domains/oyoystudios.frih.net/public_html/Forum/ftemplate.php on line 22
Antoine_935
well.

look at the error PHP is displaying

then look at your code at line PHP said (i-e 22)

Don't you see smtg ?
cr3ativ3
Oh thanks I just noticed it I thought it was talking about the { on the outside surronding the echo not the { that should be ( it works now thanks.
Related topics
*OFFICIAL* Which Browser do you use?
IE 7 to take a cue from Firefox
Windows Tips&tricks!
Basic HTML Introduction
Boot up Windows XP 60 times faster
AMD vs. INTEL
Having browser compatibility issues
What is your favourite thing in FireFox?
Visual Basic Tutorial - File I/O in VB: Text Files
Becoming a SEO Guru
Worst windows experiance
Tennis - French Open
RANDOM QUESTION: Online Identites..
Mac good stuff or bad stuff
Do Big Screens Make Employees More Productive?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.