-1

Hey getting an error on my code can anyone tell me how to fix it?

Notice: Use of undefined constant folder - assumed 'folder' in C:\xampp\htdocs\a\gallery.php on line 74

Notice: Use of undefined constant folder - assumed 'folder' in C:\xampp\htdocs\a\gallery.php on line 75

Here's the relevant section

     $path = "./images/gallery";
  $results = scandir($path);

  foreach ($results as $result) {
    if ($result !== "." and $result !== ".." and $result !== ".DS_Store"){
    //only lists the folders we want

        $folders[] = $result;
      } 
  }

  echo "<h2 id=\"galleryheaders\">";

    foreach ($folders as $folder){
      echo "<a href=\"gallery.php?folder=$folder\">$folder</a>\n";
    }



  foreach ($folders as $folder){
      echo "<?gallery = . $folder>";

    }

  echo "</h2>";

  if (isset($_GET[folder])) {
    $gallery = $_GET[folder];
  }else { 
    $gallery = $folders[0];
    };

the lines it specifically mentions are those last 2 folders

Josh Strachan
  • 39
  • 1
  • 8

1 Answers1

3

You forgot the quotes around your strings:

if (isset($_GET[folder])) {
    $gallery = $_GET[folder];
}

should be:

if (isset($_GET['folder'])) {
    $gallery = $_GET['folder'];
}
Barmar
  • 741,623
  • 53
  • 500
  • 612