Results 1 to 10 of 10

Thread: PHP Photo Album not working

  1. #1
    Join Date
    Sep 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP Photo Album not working

    1) Script Title: PHP Photo Album

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...photoalbum.htm

    3) Describe problem:

    I know there are thousands of posts about this script...

    I cant get my Script to work. I put my site on this free webspace server with php..
    http://jsdeluxe.cwsurf.de/bilder/crew/getpics.php
    But the server is not reading it..
    What could it be?

    thx for reading this.

  2. #2
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    That file looks correct to me. You understand that that file is nothing more than the javascript and needs to be referenced by an HTML file,right?

  3. #3
    Join Date
    Sep 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thx for posting..

    It should appear on this page..

    http://jsdeluxe.cwsurf.de/fotos2.html

    must be something wrong with the code?

  4. #4
    Join Date
    Sep 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I still didn't figure it out. Help

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Click on this link in a browser such as Opera or FireFox (IE will pop up a dialogue):

    http://jsdeluxe.cwsurf.de/bilder/crew/getpics.php

    You will see that the array is being populated, but that the server is adding other code to the page. Many free hosts do this. Using some more Ajax, there is probably a way around this or you also may be able to put the code (in modified form) from getpics.php directly on your fotos2.html page and rename it to fotos2.php.

    In addition to this problem, you have other scripts on fotos2.html which may be conflicting with the photo album script as well.

    And, some of your image filenames use extended characters, it is better to use just the standard English alphabet for filenames.

    First do this test and see what happens. Replace:

    Code:
                <script src="http://jsdeluxe.cwsurf.de/bilder/crew/getpics.php" type="text/javascript"></script>
                <script type="text/javascript">
    /***********************************************
    * PHP Photo Album script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
    * This notice must stay intact for legal use
    ***********************************************/
    var dimension="3x3" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc
    with:

    Code:
                <script type="text/javascript">
    var galleryarray=new Array();
    galleryarray[0]=["Alexander Friedrich.JPG", "Sep 27, 2006 02:20:55"];
    galleryarray[1]=["Gösta.JPG", "Sep 27, 2006 01:08:18"];
    galleryarray[2]=["Fred Astor.JPG", "Sep 27, 2006 01:08:00"];
    galleryarray[3]=["Ina.JPG", "Sep 27, 2006 01:08:36"];
    galleryarray[4]=["Christoph Hieke.JPG", "Sep 27, 2006 01:07:26"];
    galleryarray[5]=["Tobias Lieckefett.JPG", "Sep 27, 2006 01:11:16"];
    galleryarray[6]=["Stefan Däuwel.JPG", "Sep 27, 2006 01:10:36"];
    galleryarray[7]=["Isabella Schmid.JPG", "Sep 27, 2006 01:08:55"];
    galleryarray[8]=["Daniel Weber.JPG", "Sep 27, 2006 01:07:43"];
    galleryarray[9]=["Bea Halasa.JPG", "Sep 27, 2006 02:21:29"];
    galleryarray[10]=["Marten Werner.JPG", "Sep 27, 2006 01:09:45"];
    galleryarray[11]=["Nicolai Haller.JPG", "Sep 27, 2006 01:10:19"];
    galleryarray[12]=["Kim Smith.JPG", "Sep 27, 2006 01:09:28"];
    galleryarray[13]=["André Garbe.JPG", "Sep 27, 2006 02:21:12"];
    galleryarray[14]=["Moritz.JPG", "Sep 27, 2006 01:10:02"];
    galleryarray[15]=["Julian Schmidt.JPG", "Sep 27, 2006 01:09:11"];
    galleryarray[16]=["Tobias & Fred.JPG", "Sep 27, 2006 01:10:59"];
    /***********************************************
    * PHP Photo Album script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
    * This notice must stay intact for legal use
    ***********************************************/
    var dimension="3x3" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc
    Last edited by jscheuer1; 09-27-2006 at 06:54 PM. Reason: add info
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Sep 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thx John for replying,

    the Test works fine..
    I hope I dont have to add those lines manually in future

    I chose this server for my pics because my other one doesn't support PHP
    If it is easier I could choose a different.. or maybe you know a good one for free.

  7. #7
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    The easiest solution is to find another hosting company. I recommend that you just pay for some cheap hosting(I have found some hosts for less than a dollar a month), but if it must be free try http://www.funpic.org

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Ok, some details would need to be worked out for specific features of the script but, the basic script should work on your server with these modifications. Forget about getpics.php we are putting the php code right on the page that is using it, here is a sample for your set up, save the below as test_pic.php and put it in the root of your domain:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    
    .slideshow{ /*CSS for DIV containing each image*/
    float: left;
    margin-right: 10px;
    margin-bottom: 10px;
    }
    
    .slideshow img{ /*CSS for each image tag*/
    border: 0;
    width: 200px;
    height: 106px;
    }
    
    #navlinks{ /*CSS for DIV containing the navigational links*/
    width: 400px;
    }
    
    #navlinks a{ /*CSS for each navigational link*/
    margin-right: 8px;
    margin-bottom: 3px;
    font-size: 110%;
    }
    
    #navlinks a.current{ /*CSS for currently selected navigational link*/
    background-color: yellow;
    }
    </style>
    <script type="text/javascript">
    <?
    function returnimages($dirname="./bilder/crew/") {
       $pattern="\.(jpg|jpeg|png|gif|bmp)$";
       $files = array();
       $curimage=0;
       if($handle = opendir($dirname)) {
           while(false !== ($file = readdir($handle))){
                   if(eregi($pattern, $file)){
    		 $filedate=date ("M d, Y H:i:s", filemtime($dirname . $file));
                     echo 'galleryarray[' . $curimage .']=["' . $dirname . $file . '", "'.$filedate.'"];' . "\n";
                     $curimage++;
                   }
           }
    
           closedir($handle);
       }
       return($files);
    }
    
    echo "var galleryarray=new Array();" . "\n";
    returnimages();
    ?> 
    </script>
    </head>
    <body>
    <script type="text/javascript">
    
    /***********************************************
    * PHP Photo Album script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
    * This notice must stay intact for legal use
    ***********************************************/
    
    var dimension="3x2" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc
    var imagepath="" //Absolute path to image directory. Include trailing slash (/)
    var href_target="new" //Enter target attribute of links, if applicable
    
    //Toggle popup link setting: popupsetting[0 or 1, "pop up window attributes" (if 1)]
    var popupsetting=[1, "width=500px, height=400px, scrollbars, resizable"]
    
    //Toggle image description: descriptionprefix[0 or 1, "Text to show" (if 1)]
    var descriptionprefix=[1, "Photo "]
    
    //Sort images by date? ("asc", "desc", or "")
    //"desc" for example causes the newest images to show up first in the gallery
    //"" disables this feature, so images are sorted by file name (default)
    var gsortorder="desc"
    
    //By default, each image hyperlinks to itself.
    //However, if you wish them to link to larger versions of themselves
    //Specify the directory in which the larger images are located
    //The file names of these large images should mirror those of the original
    //Enter a blank string ("") to disable this option
    var targetlinkdir=""
    
    /////No need to edit beyond here///////////////////
    
    function sortbydate(a, b){ //Sort images function
    if (gsortorder=="asc") //sort by file date: older to newer
    return new Date(a[1])-new Date(b[1])
    else if (gsortorder=="desc") //sort by file date: newer to older
    return new Date(b[1])-new Date(a[1])
    }
    
    if (gsortorder=="asc" || gsortorder=="desc")
    galleryarray.sort(sortbydate)
    
    var totalslots=dimension.split("x")[0]*dimension.split("x")[1]
    
    function buildimage(i){
    var imagecompletepath=(targetlinkdir!="")? targetlinkdir+galleryarray[i][0] : imagepath+galleryarray[i][0]
    var tempcontainer='<a href="'+imagecompletepath+'" target="'+href_target+'" onClick="return popuplinkfunc(this)">'
    tempcontainer+='<img src="'+imagepath+galleryarray[i][0]+'" title="'+galleryarray[i][0]+' ['+galleryarray[i][1]+']" />'
    tempcontainer+='</a><br />'
    tempcontainer+=(descriptionprefix[0]==1)? descriptionprefix[1]+(i+1) : ""
    return tempcontainer
    }
    
    function jumptopage(p){
    var startpoint=(p-1)*totalslots
    var y=1;
    for (i=0; i<totalslots; i++){
    document.getElementById("slide"+i).innerHTML=(typeof galleryarray[startpoint+i]!="undefined")? buildimage(startpoint+i) : ""
    }
    while(document.getElementById("navlink"+y)!=null){
    document.getElementById("navlink"+y).className=""
    y++
    }
    document.getElementById("navlink"+p).className="current"
    }
    
    var curimage=0
    for (y=0; y<dimension.split("x")[1]; y++){
    for (x=0; x<dimension.split("x")[0]; x++){
    if (curimage<galleryarray.length)
    document.write('<div id="slide'+curimage+'" class="slideshow">'+buildimage(curimage)+'</div>')
    curimage++
    }
    document.write('<br style="clear: left" />')
    }
    
    function popuplinkfunc(imgsrc){
    if (popupsetting[0]==1){
    var popwin=open(imgsrc.href, "popwin", popupsetting[1])
    popwin.focus()
    return false
    }
    else
    return true
    }
    
    </script>
    
    <!--Below HTML code refers to the navigational links for the gallery-->
    
    <div id="navlinks">
    <script type="text/javascript">
    for (i=1; i<Math.ceil(galleryarray.length/totalslots)+1; i++)
    document.write('<a id="navlink'+i+'" href="javascript:jumptopage('+i+')\">Page'+i+'</a> ')
    document.getElementById("navlink1").className="current"
    </script>
    </div>
    </body>
    </html>
    See what happens.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Sep 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Very good, that works, except those with extendet characters, too bad..

    http://jsdeluxe.cwsurf.de/fotos3.php

    Realy thx for helping

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That's great! Just a little advice, it would be a good idea to optimize or at least resize (make them smaller) your images. This will reduce the loading time.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •