clown[NOR] Posted October 8, 2007 Share Posted October 8, 2007 Hi guys! I've been pulling my hair so much I'm going bold now. For some reason this wont work. The error message I get is: Warning: opendir(/prosjekter/001-vikhammer/thumbs) [function.opendir]: failed to open dir: No such file or directory in G:\www\mms\vis_thumbs.php on line 6 The code I use is: <?php $vis = $_GET['galleri']; $galleri = "/prosjekter/".$vis."/thumbs"; if ($handle = opendir($galleri)) { $i = 1; echo '<table border="0" cellspacing="0" cellpadding="0" width="98%">'; if ($file !== "." && $file !== "..") { while (false !== ($file == $readdir($handle))) { echo '<tr><td>'; echo '<img src="'.$file.'" border="0">'; $i++; if ($i == 6) { echo '</td></tr><tr><td>'; $i = 1; } } } closedir($handle); } ?> I tried copy paste the path printed into the URL, and it went directly into the folder.. Thanks In Advance - Clown Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/ Share on other sites More sharing options...
Orio Posted October 8, 2007 Share Posted October 8, 2007 I think you making the mistake by opening the $galleri variable with a slash. This way PHP searches the directory from the root. Try removing that slash. If that doesn't work, explain a bit about your directories' structure. Orio. Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364871 Share on other sites More sharing options...
clown[NOR] Posted October 8, 2007 Author Share Posted October 8, 2007 hmm... didnt follow you on that one... so I'ma just post the dir structure... Root - img (dir) -- "lots of images" - includes (dir) -- header.php -- footer.php - prosjekter (dir) -- 001-vikhammer --- images --- thumbs - style (dir) -- main.css - vis_thumbs.php (file) ------------------------------- did that help you any? Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364874 Share on other sites More sharing options...
The Little Guy Posted October 8, 2007 Share Posted October 8, 2007 depending on where this file sits, I can't always do "/" to go to the root, so what i have been doing lately, is doing the "../../../" method. $galleri = "../prosjekter/".$vis."/thumbs"; If you don't know what "../" is well... it does something like this: say your file is sitting here: http://mysite.com/folder1/folder2/folder3/myfile.php and you want to go to a file in folder2, you would do this: folder2 = "../file.php" folder1 = "../../file.php" for every "../" you move up one directory. Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364876 Share on other sites More sharing options...
clown[NOR] Posted October 8, 2007 Author Share Posted October 8, 2007 both "vis_thumbs.php" and "prosjekter" is in the root folder Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364880 Share on other sites More sharing options...
The Little Guy Posted October 8, 2007 Share Posted October 8, 2007 Change this: $galleri = "/prosjekter/".$vis."/thumbs"; to this: $galleri = "prosjekter/".$vis."/thumbs"; Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364882 Share on other sites More sharing options...
clown[NOR] Posted October 8, 2007 Author Share Posted October 8, 2007 that fixed that problem, but gave me a fatal error... but i fixed that one... but now all I get is a blank page... this is how my codes looks now: <?php $vis = $_GET['galleri']; $galleri = "prosjekter/".$vis."/thumbs"; if ($handle = opendir($galleri)) { $i = 1; echo '<table border="0" cellspacing="0" cellpadding="0" width="98%">'; echo "<tr><td>"; while (false !== ($file == readdir($handle))) { /*if ($file !== "." && $file !== "..") { echo '<tr><td>'; echo '<img src="'.$galleri."/".$file.'" border="0">'; $i++; if ($i == 6) { echo '</td></tr>'; $i = 1; } echo $file; }*/ echo $file; echo "test"; } echo "</td></tr>"; echo "</table>"; closedir($handle); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364884 Share on other sites More sharing options...
The Little Guy Posted October 8, 2007 Share Posted October 8, 2007 Try this: I didn't test it, so there may be a few bugs <?php $vis = $_GET['galleri']; $galleri = "prosjekter/".$vis."/thumbs"; if(is_dir($galleri)){ echo '<table border="0" cellspacing="0" cellpadding="0" width="98%">'; foreach (glob($galleri.'/*.jpg') as $file) { echo '<tr><td>'; echo '<img src="'.$file.'" border="0">'; echo '</td></tr>'; echo $file; } echo $file; echo "test"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364886 Share on other sites More sharing options...
clown[NOR] Posted October 8, 2007 Author Share Posted October 8, 2007 same thing... blank page... Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364890 Share on other sites More sharing options...
The Little Guy Posted October 8, 2007 Share Posted October 8, 2007 Did you get my modifications to the code? I changed it, you may have copied it before i modified it. so try this: <?php $vis = $_GET['galleri']; $galleri = "prosjekter/".$vis."/thumbs"; if(is_dir($galleri)){ echo '<table border="0" cellspacing="0" cellpadding="0" width="98%">'; foreach (glob($galleri.'/*.jpg') as $file) { echo '<tr><td>'; echo '<img src="'.$file.'" border="0">'; echo '</td></tr>'; echo $file; } echo $file; echo "test"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364894 Share on other sites More sharing options...
clown[NOR] Posted October 8, 2007 Author Share Posted October 8, 2007 nope same thing... all white Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364897 Share on other sites More sharing options...
The Little Guy Posted October 8, 2007 Share Posted October 8, 2007 Lets check and see if it is even finding anything. <?php $vis = $_GET['galleri']; $galleri = "prosjekter/".$vis."/thumbs"; $files = glob($galleri.'/*'); print_r($files); ?> Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364903 Share on other sites More sharing options...
clown[NOR] Posted October 8, 2007 Author Share Posted October 8, 2007 this was the result Array ( [0] => prosjekter/001-vikhammer/thumbs/S5025782.JPG [1] => prosjekter/001-vikhammer/thumbs/S5025783.JPG [2] => prosjekter/001-vikhammer/thumbs/S5025784.JPG [3] => prosjekter/001-vikhammer/thumbs/S5025785.JPG [4] => prosjekter/001-vikhammer/thumbs/S5025786.JPG [5] => prosjekter/001-vikhammer/thumbs/S5025787.JPG [6] => prosjekter/001-vikhammer/thumbs/S5025788.JPG [7] => prosjekter/001-vikhammer/thumbs/S5025789.JPG [8] => prosjekter/001-vikhammer/thumbs/S5025790.JPG [9] => prosjekter/001-vikhammer/thumbs/S5025791.JPG [10] => prosjekter/001-vikhammer/thumbs/S5025792.JPG [11] => prosjekter/001-vikhammer/thumbs/S5025793.JPG [12] => prosjekter/001-vikhammer/thumbs/S5025794.JPG [13] => prosjekter/001-vikhammer/thumbs/S5025795.JPG [14] => prosjekter/001-vikhammer/thumbs/S5025796.JPG [15] => prosjekter/001-vikhammer/thumbs/S5025797.JPG [16] => prosjekter/001-vikhammer/thumbs/S5025798.JPG [17] => prosjekter/001-vikhammer/thumbs/S5025799.JPG [18] => prosjekter/001-vikhammer/thumbs/S5025800.JPG [19] => prosjekter/001-vikhammer/thumbs/S5025818.JPG [20] => prosjekter/001-vikhammer/thumbs/S5025819.JPG [21] => prosjekter/001-vikhammer/thumbs/Thumbs.db ) Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364906 Share on other sites More sharing options...
The Little Guy Posted October 8, 2007 Share Posted October 8, 2007 Lets find out if it is going into that if statement i made. <?php $vis = $_GET['galleri']; $galleri = "prosjekter/".$vis."/thumbs"; if(is_dir($galleri)){ echo 'Directory '.$galleri.' DOES EXIST!!!'; }else{ echo 'Directory '.$galleri.' DOES NOT EXIST '; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364913 Share on other sites More sharing options...
clown[NOR] Posted October 8, 2007 Author Share Posted October 8, 2007 Directory prosjekter/001-vikhammer/thumbs DOES EXIST!!! Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364916 Share on other sites More sharing options...
SammyGunnz Posted October 8, 2007 Share Posted October 8, 2007 I'm personally going italic....but that's just me. Sorry...had to. Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364917 Share on other sites More sharing options...
clown[NOR] Posted October 8, 2007 Author Share Posted October 8, 2007 thanks Little Guy... just modified some of your codes and now it works perfect... the final result: <?php $vis = $_GET['galleri']; $galleri = "prosjekter/".$vis."/thumbs"; $files = glob($galleri.'/*'); echo '<table border="0" cellspacing="2" cellpadding="0" width="98%">'; echo '<tr>'; $i=1; foreach ($files as $file) { $ext = explode(".", $file); if ($ext[1] == "JPG") { echo '<td><img src="'.$file.'" border="0"></td>'; $i++; if ($i == "6") { echo '</tr><tr>'; $i=1; } } } echo '</tr>'; echo '</table>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364920 Share on other sites More sharing options...
The Little Guy Posted October 8, 2007 Share Posted October 8, 2007 This works on my server: <?php $vis = $_GET['galleri']; $galleri = "prosjekter/".$vis."/thumbs"; if(is_dir($galleri)){ echo '<table border="0" cellspacing="0" cellpadding="0" width="98%">'; foreach (glob($galleri.'/*') as $file) { echo '<tr><td>'; echo '<img src="'.$file.'" border="0">'; echo '</td></tr>'; echo $file; } echo $file; echo "test"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/72354-solved-please-help-me-going-bold-over-this-problem/#findComment-364923 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.