Note that there are some explanatory texts on larger screens.

plurals
  1. PONo such directory while using a variable string in url (PHP)
    primarykey
    data
    text
    <p>Well, the title is probably not very helpful. I'm not sure how to describe this error. I'm sure it's caused by something stupid on my part. For the life of me though, I can't figure it out.</p> <p>Here's what I'm trying to do: There's a list of folders in my directory "img/gallery"</p> <p>Within each of those folders are images</p> <p>There's also a folder called "img/thumbs" which is structured exactly the same but with thumbnail images</p> <p>I am writing a script that does two things: it displays the names of the folders within "img/gallery" and displays a list of thumbnails with links to the images in that folder.</p> <p>These two components, when run separately, work fine. Put together, I get an error at</p> <p><code>if ($handle = opendir('img/gallery/$file/'))</code></p> <p>saying that $file is not a valid directory. </p> <p>Here's the code:</p> <p>` <pre><code>if ($handle = opendir('img/gallery/')) { $blacklist = array('.', '..', 'somedir', 'somefile.php'); while (false !== ($file = readdir($handle))) { if (!in_array($file, $blacklist)) { echo "&lt;h2&gt;$file&lt;/h2&gt;\n"; } } closedir($handle); } echo "&lt;P class='gallery'&gt;\n"; if ($handle = opendir('img/gallery/$file/')) { while (false !== ($entry = readdir($handle))) { if ($entry != "." &amp;&amp; $entry != "..") { echo "&lt;a class='fancybox' href='img/gallery/$file/$entry' data-fancybox-group='gallery'&gt;\n&lt;img src='img/thumbs/$file/$entry' alt='' /&gt;&lt;/a&gt;\n"; } } echo "&lt;/p&gt;\n"; closedir($handle); } </code></pre> <p>`</p> <p>And advice would be wonderfully helpful. Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload