Ankündigung

Einklappen
Keine Ankündigung bisher.

[Erledigt] VARIABLEN WERDEN NICHT RICHTIG VERARBEITET!!!! HILFE

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • [Erledigt] VARIABLEN WERDEN NICHT RICHTIG VERARBEITET!!!! HILFE

    Brauche unbedingt HILFE. Komme alleine einfach nicht mehr weiter. BITTE UM HILFE!!! Bin für jede Hilfe sehr dankbar!!!!


    Auf der ersten Seite "forums.html" möchte ich eine Variable festlegen (die Variable beinhaltet
    den ausgewählten Ordnernamen) die an die Datei "imagegallery.php" übergeben wird.
    Möchte einen Link auf der Seite index.php anklicken. z.B. hochzeit. Dann soll der Ordnername
    hochzeit an imagegallery.php gesendet werden und die imagegallery.php soll den unterordner
    "bilder" und "thumbs" aus dem Ordner Hochzeit auslesen?
    Das Problem ist, dass die Variablen nicht richtig im imagegallery.php erkannt werden!??
    Die thumbnails werden richtig angezeigt, aber beim Ancklicken von einem thumb bekomme ich eine
    Fehlermeldung. Pfad nicht gefunden... Warum ???

    Struktur:

    --> Bildergalerie [ Ordner ]
    --> index.php[ Datei ]
    --> imagegallery.php [ Datei ]
    --> hochzeit[ Unterordner von Bildergalerie ]
    --> bilder[ Unterordner von hochzeit]hier sind die grossen bilder drin
    --> thumbs[ Unterordner von bilder ]hier sind die thumbnails
    --> Geburtstag [ Unterordner von Bildergalerie ]
    --> bilder[Unterordner von Geburtstag]hier sind die grossen bilder
    --> thumbs[ Unterordner von bilder]hier sind die thumbnails

    u.s.w

    --------------------------------
    index.php
    --------------------------------
    PHP-Code:
    <?php 
    $verz
    =opendir ('.');
    while (
    $file readdir ($verz)) 

    {  
    if(
    $file != "." && $file != ".." && is_dir($file))
    echo 
    "  <a href=\"imagegallery.php?galerie=$file\"><img src=\"loeschen.bmp\" alt=\"Löschen\" border=\"0\"></a>  ";
    }
    closedir($verz); 
    ?>
    ---------------------------------


    So werden die Variablen definiert.

    $kleinebilder = $_GET[ galerie ]."/".thumbs;
    $grossebilder = $_GET[ galerie ];


    und übergeben an:



    ----------------------------------
    imagegallery.php
    ----------------------------------
    PHP-Code:
    <html>
    <head>
    <title>Simple PHP Image Gallery</title>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <style type="text/css">
    <!--
    /* Default styles incase you don't have an external css. */
    body { background-color: rgb(56,56,56); color: rgb(180,180,180); font: 82% verdana, arial, sans-serif }
    table { font-size: inherit }
    p, td, div { color: rgb(180,180,180); font-family: verdana, arial, sans-serif }
    h2 { font-size: 1.2em; font-weight: bold }
    h2, p { text-align: center }

    a:link, a:active, a:visited { color: #708090; text-decoration: none; font-size: 12px }
    a:hover { text-decoration: underline }

    /* the following styles must be included somewhere, since they controll all formatting */
    #photo { text-align: center }
    #photo table { width: 80%; text-align: center; margin-right: auto; margin-left: auto }
    #photo table td { padding: 0px 10px 10px 10px }
    #photo .fulltitle { margin-bottom: 0px; padding-bottom: 0px }
    #photo .series { margin-top: 0px; padding-top: 0px }
    br.hideme { visibility: hidden; volume: silent }
    /* hidden from netscape 4: */
    div#photo img { border: 1px solid #708090 } 
    div#photo .caption { text-align: left; width: 500px; margin-right: auto; margin-left: auto }
    -->
    </style>

    </head>
      
    <body>

    <h2>Image Gallery</h2>



    Insert snappy caption here.</p>


    <div id="photo">
    <?
    //error_reporting (E_ALL);


    // 1 for XHTML or 0 for HTML?
    $xhtml = 1;

    ###############################################################


    $kleinebilder = $_GET[ galerie ]."/".thumbs;
    $grossebilder = $_GET[ galerie ];


    // thumbnail directory name
    $thumbs_dir = $kleinebilder;

    // full size image directory name
    $full_dir = $grossebilder;

    ###############################################################


    // captions directory name (captions are option, ignore if you dont' have any)
    $captions_dir = 'captions';

    // thumbnails title (1 to show, 0 to hide)
    $thumb_title = 1;

    // full size images title (1 to show, 0 to hide)
    $full_title = 1;

    // kill beginning numbers for the title (1 to hide, 0 to show)
    // hiding would make 0005_baby_pic.jpg have a title of 'Baby pic'
    $kill_title_nums = 1;

    // how many thumbnails should appear per row? (3 usually looks best)
    $cols = 5;

    // how many thumbnails per page? (a multiple of $cols, or 0 for all)
    $max_thumbs = 0;

    // extension name (if your server is not set for "index.$ext to be the index page, put 0)
    $ext = 'php';

    // captions extension
    $cext = 'inc';  // use whatever you're comfortable with

    // show random option for single page view (1 to show, 0 to hide)
    $showrand = 0;

    // closing (X)HTML options
    // if you use a function to close your code, put that in, otherwise leave as is
    $print_footer = 'print_footer';


    // figure out this script's name
    $self = $_SERVER['PHP_SELF'];

    if (basename($self) == "index.$ext") {
        $self = str_replace(basename($self), '', $self);
    }

    // do you have an existing function to close your page?  if not, use this default...
    if (!function_exists($print_footer)) {
        function print_gallery_footer() {
    ?>

    </body>
    </html>
    <?
        }
        $print_footer = 'print_gallery_footer';
    }

    // our error function, cleanly exits the script on user errors
    function imgerror($error) {
        global $print_footer;
        print "

    [b]$error[/b]</p>\n\n";
        $print_footer();
        exit();
    }

    // check to see which kind of closing tag we should use
    $close_tag =  !empty($xhtml) ? ' />' : '>';

    // check for directories
    if (!is_dir($thumbs_dir)) {
      imgerror('Directory "'.$thumbs_dir.'" does not exist.');
    }

    if (!is_dir($full_dir)) {
      imgerror('Directory "'.$full_dir.'" does not exist.');
    }

    // get contents of $thumbs_dir
    $dir = @opendir($thumbs_dir) or imgerror('Can\'t open ' . $thumbs_dir . ' directory');

    while (($thumb = readdir($dir)) !== false) {
        if (preg_match('/((?i)jpg|jpeg|gif|tif|bmp|png)$/', $thumb))
            $thumbs[] = $thumb;
    }

    natcasesort($thumbs);
    $thumbs_size = sizeof($thumbs);

    // lowest displayed image in the array
    // use http_get_vars incase register_globals is off in php.ini
    $i = !empty($_GET['i']) ? $_GET['i'] : 0;

    $random = array_rand($thumbs, 2);
    $i = $i === 'rand' ? $thumbs[$random[rand(0, 1)]] : $i;

    // check to see if all thumbs are meant to be displayed on one page
    if ($max_thumbs == 0) {
        $max_thumbs = $thumbs_size;
        $mt_check = 1;
    }

    // thumbnail view
    if (is_numeric($i)) {
        // check to see which thumbnail to start with
        $start = empty($mt_check) && $i > 0 ? $max_thumbs * ($i - 1) : 0;
        // are they looking for thumbs pages that don't exist?
        if ($start >= $thumbs_size) {
            print '[url="' . $self . '"]index[/url]' . "\n\n";
            imgerror('Sorry, there are no images to display on this page');
        }
    ?>
    <table>

    <tr>
    <?
        // loop through $thumbs and display $max_thumbs per page
        for ($count = 1; $count <= $max_thumbs; $start++) {
            // break if past max_thumbs
            if ($start >= $thumbs_size) {
                break;
            }
            
            // print new row after predefined number of thumbnails
           if (($count % $cols == 1) && $count != 1 && $cols > 1) {
                print "</tr>\n\n<tr>\n";
            } elseif ($cols == 1) {
                print "</tr>\n\n<tr>\n";
            }
            
           // open cell
            print '<td align="center" style="width: ' . (floor(100 / $cols)) . '%">';
            
           // insert thumb
            print '<a href="' . $self . '?i=' . rawurlencode($thumbs[$start]) . '">';
            print '[img]' . $thumbs_dir . '/' . rawurlencode($thumbs[$start]) . '[/img]';
            
            // image title
           if ($thumb_title) {
                if ($kill_title_nums) {
                    $title = ltrim(ltrim(str_replace('_', ' ', $thumbs[$start]), "0..9"));
                } else {
                    $title = ltrim(str_replace('_', ' ', $thumbs[$start]));
                }
                
                $title = explode(".", ucfirst($title));
                print '<br' . $close_tag . "\n" . $title[0];
            }
            
            // close cell
            // supress line break for screen readers, but force a line break for lynx
            print '<br class="hideme"' . $close_tag . '</td>' . "\n";
            $count++;
        }
    ?>
    </tr>

    </table>
    <?
        // thumbs page nav
        if (!$mt_check) {
            print "\n

    ";
            // how many total thumbs pages, including a "remainder" page if needed
            $pages = ceil($thumbs_size / $max_thumbs);
            for ($count = 1; $count <= $pages; $count++) {
                if ($count == 1) {
                    if ($count == $i || $i == 0) {
                        print $count;
                    } else {
                        print "<a href=\"$self\">$count</a>";
                    }
                } else {
                    if ($count == $i) {
                        print " | $count</a>";
                    } else {
                        print " | <a href=\"$self?i=$count\">$count</a>";
                    }
                }
            }
            print '</p>';
        }
    }

    // single image view
    else if (file_exists("$full_dir/$i")) {
        // find where it is in the array
        $key = array_search($i, $thumbs);
        if (is_null($key)) {
            $key = -1;
        }

        // navigation
        print '

    ';
        

        // previous
        print $key >= 1 ? '<a href="' . $self . '?i=' . rawurlencode($thumbs[$key - 1]) . '">' : '';
        print '&laquo; previous';
        print $key >= 1 ? '</a>' : '';
        print ' | ';

        // index
        print '[url="' . $self . '"]index[/url]';
        print ' | ';
        
        // random
        if ($showrand != 0) {
            print '[url="' . $self . '?i=rand"]random[/url]';
          print ' | ';
        }
        
        // next
        print $key < $thumbs_size - 1 ? '<a href="' . $self . '?i=' . rawurlencode($thumbs[$key + 1]) . '">' : '';
        print 'next &raquo;';
        print $key < $thumbs_size - 1 ? '</a>' : '';

        print "</p>\n\n";
        // image
        print '[img]' . $full_dir . '/' . rawurlencode($i) . '[/img]$title[0]</div>\n\n";
        }

        // numerically show what image it is in the series; hide this if image isn't in the series
        if ($key >= 0) {
            // add 1 so that the first image is image 1 in the series, not 0
            print '<div class="series">' . ($key + 1) . ' of ' . $thumbs_size . "</div>\n\n";
        }

        // caption (optional)
        if (file_exists("$captions_dir/$i.$cext")) {
            print '<div class="caption">' . "\n";
            require("$captions_dir/$i.$cext");
            print "\n</div>\n";
        }
    } else {  // no image found
    ?>

    [url="<?=$self?>"]index[/url]</p>

    <?
        imgerror('Sorry, that image does not exist...');
    }
    ?>
    </div>




    [url="../"]Back to main image gallery[/url]</p>

    </body>
    </html>

  • #2
    also weil ich mal noch gnädig bin, hier der link, auf den ersten blick würde ich sagen das ist dein problem:

    http://www.phpfriend.de/ftopic26569.html

    aber bei dem zeug und wie du es gepostet hast ... naja ich spar mir den rest.

    Der Beitrag wurde verschoben, wegen...
    ... unangemessenem Verhalten/Benehmen.
    ... unzureichender Fragestellung.
    ... unzureichender Hintergrund-Informationen.
    ... unzureichendem Titel.
    ... Postings im falschen Forum. Bitte beim nächsten Mal darauf achten..
    ... Sinnbefreitheit.
    ... der Tatsache, dass die Suchfunktion (und google) auch was feines ist.

    Bemerkung:
    Die gestellte Frage entspricht nicht dem Wissensstand eines/einer Fortgeschrittenen.
    Die gestellte Frage entspricht nicht dem Wissensstand eines Profis. Dazu: http://www.phpfriend.de/forum/viewtopic.php?t=21431
    Bei Einspruch oder weiteren Fragen bitte an mich wenden.

    moved to PHP - Anfänger

    mfg
    robo47
    [URL="http://www.robo47.net"]robo47.net[/URL] - Blog, Codeschnipsel und mehr
    | :arrow: [URL="http://www.robo47.net/blog/192-Caching-Libraries-and-Opcode-Caches-in-php-An-Overview"]Caching-Klassen und Opcode Caches in php[/URL] | :arrow: [URL="http://www.robo47.net/components"]Robo47 Components - PHP Library extending Zend Framework[/URL]

    Kommentar


    • #3
      Wie übergibst Du denn die Variablen $thumbs_dir usw. an die imagegallery.php ?
      Du schreibst nur, dass Du es tust, aber nicht wie.
      mod = master of disaster

      Kommentar


      • #4
        Die Variable werden folgendermaßen übergeben:

        $kleinebilder = $_GET[ galerie ]."/".thumbs;
        $grossebilder = $_GET[ galerie ];


        D.h. Im index.php werden die variablen gesetzt: Der Ordnername wird übergeben!
        galerie=$file
        und das imagegallery.php übergeben!

        // thumbnail directory name
        $thumbs_dir = $kleinebilder;

        // full size image directory name
        $full_dir = $grossebilder;

        Es funktioniert auch soweit dass die Thumbnails angezeigt werden. Doch wenn ich
        ein thumbnail anklicke, wird der Pfad nicht erkannt.

        ligt es vielleicht daran???
        -------

        PHP-Code:
        <?php
        $thumbs_dir 
        $kleinebilder

        $kleinebilder $_GETgalerie ]."/".thumbs

        if (!
        is_dir($thumbs_dir)) { 
        imgerror('Directory "'.$thumbs_dir.'" does not exist.'); 

        ?>
        ---------------------
        geht das nicht? ich bin am verzweifeln. Ich weiss auch nicht ob ich mein problem
        verständlich genug geschildert hab....

        Danke im voraus.!!!!!

        Robo47. Dein Tip werde ich mir auch anschauen. Danke!

        Kommentar


        • #5
          Zitat von miba
          Der Ordnername wird übergeben!
          galerie=$file und das imagegallery.php übergeben!
          Ich sehe hier keine Antwort auf die Frage, wie übergeben wird.
          mod = master of disaster

          Kommentar


          • #6
            also ich glaube der fehler ist hier:
            Auf der ersten Seite "forums.html" möchte ich eine Variable festlegen ..
            gibts neuerdings in html schon variablen?



            mfg andi

            Kommentar


            • #7
              @ Waq
              ---------
              Also ich habe mich etwas unverständlich ausgedrückt... Sorry!

              Die Startseite heisst nicht "forums.html" sondern index.php!!!!

              Die Datei index.php wird gestartet. Sie lest alle Ordner aus dem Verzeichnis aus, indem sie sich befindet. Die Unterordner also. z.b. hochzeit und geburtstag werden
              als "link" angezeigt: Mit dem script: Sorry ist etwas chotisch... jetzt geändert...

              -------------------------
              index.php
              -------------------------
              php]<?php
              $verz=opendir ('.');
              while ($file = readdir ($verz))

              {
              if($file != "." && $file != ".." && is_dir($file))
              echo " <a href=\"imagegallery.php?galerie=$file\"><img src=\"ordner.bmp\" alt=\"ordner\" border=\"0\"></a> ";
              }
              closedir($verz);
              ?>[/php]


              -----------------------------
              Es wird der Ordnername $file übergeben...

              klicke ich zb. Ordner "hochzeit" an, so öffnet sich die Seite "imagegallery.php" und
              übernimmt die Variable 'galerie'.

              Das geschieht mit $_GET[galerie]

              Der Ordnername ist also $grossebilder denn :

              $grossebilder = $_GET[ galerie ];
              in dem Ordner befinden sich die "grossen" Bilder.

              Weiterhin definiere ich die Variable $kleinebilder denn die thumbnails befinden sich
              im Unterordner thumbs.

              $kleinebilder= $_GET[ galerie ]."/".thumbs

              Habe also fogende Struktur:

              Der in der index.php ausgewählte Ordnername z.B. hochzeit wird an imagegallery.php übergeben und zugleich wird der unterordner /thumbs definiert.

              Dann heisst es :

              // thumbnail directory name
              $thumbs_dir = $kleinebilder;

              // full size image directory name
              $full_dir = $grossebilder;

              . Wie gesagt die thumbnails werden angezeigt. Nur nicht die grossen Bilder.

              Ich denke dass die Variablen irgendwo mitten im script imagegallery.php nicht richtig übernommen werden. Aber wo ist der Fehler. Ich sitzte Tag und Nacht an dem Script und kriege es nicht hin.

              Vielleicht kann es jemand ausprobieren???? Ich weiss nicht mehr weiter....

              Danke weiterhin für jede Hilfe...

              Kommentar

              Lädt...
              X