Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Some Help Required - Bug spotting

Featured Replies

Hi folks.

 

Today i started building an image gallery for a site i'm working on.

 

I'm coding it in php/mysql . i'm also using javascript files; prototype, lightbox, scriptaculous.

 

I've managed to successfully code the admin section but i'm having a little trouble with the main part.

 

 

The idea is, images are taken from mysql database, thumbnails are displayed and when the thumbnails are clicked the full size image is displayed (similar to http://sidebarcreative.com/portfolio/)

 

So far, the thumbnails are showing up ok but i can't seem to get it to work with lightbox

 

here is the seciton of code i think has a bug, hopefully someone can point it out.

 

echo '<div id="images">';
       $select = mysql_query("SELECT * FROM gallery ORDER BY id DESC") or die(mysql_error());
       while($r = mysql_fetch_array($select)){
           extract($r);
           echo "<a href=\"/gallery/images/" . $basename . "\" rel=\"lightbox[deadworlds]\" title=\"" . $description . "\"><img src='$image' alt='$title' /></a>";
       }
       echo '</div>';

 

 

I think the problem lies within:

 

echo "<a href=\"/gallery/images/" . $basename . "\" rel=\"lightbox[deadworlds]\" title=\"" . $description . "\">...

 

 

Help would be much appreciated. thanks in advance!

echo "<a href=\"/gallery/images/" . $basename . "\" rel=\"lightbox[deadworlds]\" title=\"" . $description . "\">...

 

could you post the generated html

 

Pat

  • Author

Sure thing:

 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script src="javascripts/prototype.js" type="text/javascript"></script>
<script src="javascripts/scriptaculous.js" type="text/javascript"></script>
<script type="text/javascript" src="/javascripts/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="/javascripts/lightbox.js"></script>
<link rel="stylesheet" href="lightbox.css" type="text/css" media="screen" />
<script type="text/javascript">
var slideshowr = new Array();

function bigImage(picture, title, description){
   var image = $("images");
   var images = image.getElementsByTagName("img");
   for(var i = 0; i < images.length; i++){
       Effect.Fade(images[i])
   }

   var div = document.createElement("div");
   div.innerHTML = "<b>"+title+"</b>";
   div.innerHTML = div.innerHTML + "<p>"+description+"</p>";
   div.innerHTML = div.innerHTML + "<img src='"+picture+"' alt='"+title+"' /><br />";
   div.innerHTML = div.innerHTML + "<a href='#' onclick='closePicture()'>Close</a>";
   div.id = "bigpicture";
   div.style.display = "none";
   document.body.appendChild(div);
   Effect.Grow("bigpicture");
}

function closePicture(){
   Effect.Fade("bigpicture");

   var image = $("images");
   var images = image.getElementsByTagName("img");
   for(var i = 0; i < images.length; i++){
       Effect.Grow(images[i])
   }
}

function slideshowarray(title, picture, description){
   slideshowr.push(new Array(picture, title, description));
}

function slideshow(link){
   var picture = $("picture");
   if(slideshowr.length >= 1){
   picture.innerHTML = "<b>"+slideshowr[0][1]+"</b>";
   picture.innerHTML += "<p>"+slideshowr[0][2]+"</p>";
   picture.innerHTML += "<img src='"+slideshowr[0][0]+"' alt='"+slideshowr[0][1]+"' />";
   slideshowr.reverse();
   slideshowr.pop();
   slideshowr.reverse();
   if(link != 0){
   setTimeout("slideshow()", 10000);
   }
   }
   else {
       picture.innerHTML += "<br />Slideshow has finished.<br />";
       picture.innerHTML += "<a href='gallery.php?action=slideshow'>Start Again?</a>";
   }
}
</script>
<style type="text/css">
* { 
   font-size: 14px;
   line-height: 150%; 
}
body { 
   font-family: Trebuchet MS, Verdana, Arial, sans-serif;
   background: url(gradient.jpg);
   background-repeat: repeat-x; 
}
h1 { 
   margin-left: 10em; 
}
h1 a {
   font-size: 1.75em;
}

#slideshow {
   margin-left: 5em;
   font-size: 1.5em;
}

/* Images */

#images {
   padding: 2em;
}

#images img {
   width: 150px;
   height: 150px;
   margin-right: 1em;
}

#bigpicture { 
   background-color:#CFDCE6;
   padding:2em;
   border:2px solid black;
}    
</style>
</head>

<body>
<h1><a href="gallery.php">Image Gallery</a></h1>
<h2>What Were About</h2>

   <div id="images"><a href="/gallery/images/09-11-2008-8-9-18-sideshow.png" rel="lightbox[deadworlds]" title="Here is a test image"><img src='http://deadworlds.leeboyce.calitechhosting.co.uk/gallery/images/09-11-2008-8-9-18-sideshow.png' alt='Image' /></a></div><!---->
</body>
</html>

  • Author

sorry, never noticed the codebox was going to be that wide. also, the code needs some tidying, theres things i wont be using that need taken out.

sorry, never noticed the codebox was going to be that wide. also, the code needs some tidying, theres things i wont be using that need taken out.

 

you could give this a try

 

echo "<a href=\"gallery/images/" . $basename . "\" rel=\"lightbox[deadworlds]\" title=\"" . $description . "\">...

 

Pat

  • Author

Just tried it,

 

Not Found:

The requested URL /gallery/gallery/images/09-11-2008-8-9-18-sideshow.png was not found on this server.

  • Author

You can see here: http://deadworlds.leeboyce.calitechhosting...allery/view.php

 

When the thumbnail is clicked it just goes to the image.

 

Whereas i want it to do the same as i have here when you click the links: http://deadworlds.leeboyce.calitechhosting...ex.php?sideshow

Just tried it,

 

Not Found:

The requested URL /gallery/gallery/images/09-11-2008-8-9-18-sideshow.png was not found on this server.

 

Looks like it is a problem with the lightbox settings and not with your script

 

Pat

  • Author

Ah right ok.

 

I'll have a look at that then. I find it a little weird though that it works for my other page, hence why i thought it was the code that was wrong.

 

Thanks for your help :D

Ah right ok.

 

I'll have a look at that then. I find it a little weird though that it works for my other page, hence why i thought it was the code that was wrong.

 

Thanks for your help :D

 

On the page it works, the link to the css is

<link rel="stylesheet" href="sideshow/lightbox.css" type="text/css" media="screen" />

 

And on the page not working

 

 

<link rel="stylesheet" href="lightbox.css" type="text/css" media="screen" />

 

Also try removing the inline css

 

Pat

on inspection of the included javascript you are getting lots of 404's namley the lightbox js file.... so this explains the lack of javascript

 

[i used the web developer toolbar for firefox, to check click information>view javascript]

 

http://deadworlds.leeboyce.calitechhosting...pts/lightbox.js

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /javascripts/lightbox.js was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
<hr>
<address>Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8b mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.5 Server at deadworlds.leeboyce.calitechhosting.co.uk Port 80</address>
</body></html>

 

try doing full path includes and see if that sorts it out

  • Author

Man, i'm such a tit.

 

The problem was that prototype.js and scriptalusous.js call on other files such as effects.js

 

I hadn't uploaded them, they are now uploaded and i have it working.

 

Thanks for the help guys, i feel like i've wasted your time with such a pathetic solution.

 

Thanks!

  • Author

Now i have the barebones, i'll try not to incorporate it into my design properly.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.