Results 1 to 6 of 6

Thread: PHP Photo Album script

  1. #1
    Join Date
    Dec 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP Photo Album script

    I'm trying to implement this script, but I'm having some difficulty.

    I have followed the directions and double checked the work...I'm getting an error in FrontPage saying that I have a syntax error on line 2 which is the first <head> line below. I'm also getting 2 errors saying galleryarray isn't defined.

    Any help?

    SWest

    <html>
    <head>
    <title>selfserv.gif</title>


    </script>


    <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: 0px none;
    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>

    </head>

  2. #2
    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

    This is the galleryarray from the demo:

    Code:
    //Specify images:
    //galleryarray[x]=["path_to_image", "optional_title_attribute", "optional_text_description", "optional_link"]
    var galleryarray=new Array()
    galleryarray[0]=["photo1.jpg", "optional title", "optional description", "optional url"]
    galleryarray[1]=["photo2.jpg", "optional title", "optional description", "optional url"]
    galleryarray[2]=["photo3.jpg", "optional title", "optional description", "optional url"]
    galleryarray[3]=["photo4.jpg", "optional title", "optional description", "optional url"]
    galleryarray[4]=["photo5.jpg", "optional title", "optional description", "optional url"]
    galleryarray[5]=["photo6.jpg", "optional title", "optional description", "optional url"]
    galleryarray[6]=["photo7.jpg", "optional title", "optional description", "optional url"]
    If you are getting an error that it is not defined, something is wrong with your syntax or you have left it out altogether. There could also be other problems. To be more specific, I would need to see your page:

    PLEASE: Include the URL to your problematic webpage that you want help with.
    - John
    ________________________

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

  3. #3
    Join Date
    Dec 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Code:
    </script>
    
    
    <style type="text/css">
    There is a </script> there which appears to be sitting all alone... is this the problem?

    As jscheuer1 says without a page it very difficult to see what is going on.

  4. #4
    Join Date
    Dec 2005
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking

    There is a </script> there which appears to be sitting all alone... is this the problem?

    remove the </script>...it should not be there. also, make sure to add the following code in after the <body> tag and make sure alle the images are named properly.

    Code:
    <script type="text/javascript">
    
    /***********************************************
    * 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
    
    //Specify images:
    //galleryarray[x]=["path_to_image", "optional_title_attribute", "optional_text_description", "optional_link"]
    var galleryarray=new Array()
    galleryarray[0]=["photo1.jpg", "optional title", "optional description", "optional url"]
    galleryarray[1]=["photo2.jpg", "optional title", "optional description", "optional url"]
    galleryarray[2]=["photo3.jpg", "optional title", "optional description", "optional url"]
    galleryarray[3]=["photo4.jpg", "optional title", "optional description", "optional url"]
    galleryarray[4]=["photo5.jpg", "optional title", "optional description", "optional url"]
    galleryarray[5]=["photo6.jpg", "optional title", "optional description", "optional url"]
    galleryarray[6]=["photo7.jpg", "optional title", "optional description", "optional url"]
    
    var href_target="_new" //Enter target attribute of links, if applicable
    
    var totalslots=dimension.split("x")[0]*dimension.split("x")[1]
    
    function buildimage(i){
    var tempcontainer=galleryarray[i][3]!=""? '<a href="'+galleryarray[i][3]+'" target="'+href_target+'">' : ""
    tempcontainer+='<img src="'+galleryarray[i][0]+'" border="1" title="'+galleryarray[i][1]+'">'
    tempcontainer=galleryarray[i][3]!=""? tempcontainer+'</a>' : tempcontainer
    tempcontainer=galleryarray[i][2]!=""? tempcontainer+'<br \/>'+galleryarray[i][2] : tempcontainer
    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" />')
    }
    
    </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>

  5. #5
    Join Date
    Jan 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default php fix

    I was experiencing the same problem with the 'galleryarray' I changed the php script from:

    ...................................................................................................
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
    <BODY><PRE>&lt;?
    Header("content-type: application/x-javascript");

    function returnimages($dirname=".") {
    $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($file));
    echo 'galleryarray[' . $curimage .']=["' . $file . '", "'.$filedate.'"];' . "\n";
    $curimage++;
    }
    }

    closedir($handle);
    }
    return($files);
    }

    echo "var galleryarray=new Array();" . "\n";
    returnimages();
    ?&gt;
    </PRE></BODY></HTML>

    ...........................................................................................

    to:

    ...........................................................................................

    <?
    Header("content-type: application/x-javascript");

    function returnimages($dirname=".") {
    $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($file));
    echo 'galleryarray[' . $curimage .']=["' . $file . '", "'.$filedate.'"];' . "\n";
    $curimage++;
    }
    }

    closedir($handle);
    }
    return($files);
    }

    echo "var galleryarray=new Array();" . "\n";
    returnimages();
    ?>

    ...................................................................................................

    and it worked.

  6. #6
    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 just a matter of the code getting mangled somewhere along the way as:

    <PRE>&lt;?

    was never in the distribution.
    - 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
  •