View Full Version : PHP Photo Album script v2.11 Images Won't Display

05-30-2011, 10:26 PM
1) PHP Photo Album script v2.11

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

3) Describe problem:
I am unable to see the images using the Photo Album script. If I point to the demo images on DynamicDrive, the images load fine. When I point to the images on the server I am using, nothing loads. When I run the getalbumpics.php file, I get the following error: "alert("Photo Album ID must contain only letters, numbers, or underscore, and cannot start with a number")". I have tried loading the images and php file on 3 different servers that I have access to and I get the same error. They are Linux servers, I don't know the details, it's a GoDaddy and Yahoo hosting servers. I did not edit the getalbumpics.php file. Here is a link to the file that I have built. The required js and css files are at this same directory level.

Thank you!

05-30-2011, 11:16 PM
This script requires a PHP enabled server (host). From the looks of things, the server for this host account is not PHP enabled.

If you know different, perhaps you need to turn it on or something. Otherwise you need a different host or need to contact your host to see if PHP can be enabled for the account.

In any case, the getalbumpics.php file is not being interpreted as PHP, rather it's being interpreted as ordinary javascript text.

05-31-2011, 03:04 AM
Thank you John. I checked with the hosting company and they said the PHP is enabled and is running version 5. The script still gives the error message. I don't want to chew up your time but I'm not sure where to turn. I'm only technical enough to be dangerous. If you have any thoughts or further ideas, I'll gladly take them. Otherwise, I'll start making a Plan B. Thank you.


05-31-2011, 03:40 AM
That getalbumpics.php file won't work in many PHP 5 setups. Here:


is an updated one that will in all PHP 5 and still works in PHP 4.

Perhaps you will have better luck with it.

However, looking at that (the one that was there when I checked before) file on the server, there weren't any error messages. So unless it follows strict syntax (also corrected for in the updated version at the link above), the host isn't even trying to interpret it as PHP.

Give it a shot. If it works - great! If not, leave the updated version in place for me to have a look at.

05-31-2011, 04:24 AM
Hi John,
It didn't work. This hosting account is a free one and displays ads, looks bad. I will try and convince client to upgrade which will eliminate ads. Could that be the problem? Thank you for your continued efforts and quick replies!


05-31-2011, 04:43 AM
Well the good news is that the host is PHP enabled and that the file works.

The bad news is as you say, they put an ad at the end.

We might be able to overcome that by adding (highlighted and red) to near the end or our updated getalbumpics.php file:

echo " desc: []\n";
echo "}\n/*";

Just checked, that won't work.

05-31-2011, 05:13 AM
I'll see if we can get rid of he ads, hopefully that works. Thanks again John!


05-31-2011, 09:28 AM
I tested the concept and it doesn't work. You might be able to get the ads turned off for the one file. The ads would never be seen anyway.

Another option would be to make the page, in this case test4.html, a PHP page (test4.php). Then we could put a modified version of the PHP code from getalbumpics.php right on the page. Ads would no longer be a problem because, although the page would still have them, they wouldn't be in a spot that interferes with the code.

So on the now renamed test4.php page, replace:

<script type="text/javascript" src="http://www.freshmeadowscranberries.com/images/history/getalbumpics.php?id=jaguar"></script>


<script type="text/javascript">
$photovar = 'jaguar';
$dirname = 'images/history/';

if (phpversion() >= 5.1){

function returnimages() {
global $dirname;
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(preg_match($pattern, $file)){
$filedate=date ("M d, Y H:i:s", filemtime($dirname . $file));
echo " [$curimage, \"$file\", \"$filedate\"],\n";
echo ' ["placeholder"]' . "\n";

if (!preg_match('/^[a-z_][a-z0-9_]+$/i', $photovar)){
echo 'alert("Photo Album ID must contain only letters, numbers, or underscore, and cannot start with a number")';
echo "var $photovar={\n";
echo " baseurl: \"http://" . $_SERVER["SERVER_NAME"] . dirname($_SERVER['PHP_SELF']) . "/" . $dirname . "\",\n";
echo " images: [\n";
echo " ],\n";
echo " desc: []\n";
echo "}\n";

Notice the two highlighted variables at the beginning. The $photovar is the same as what would have been id from the old method, and the $dirname is the relative path to the images.

I've already set them to what they need to be for test4.php.

05-31-2011, 12:58 PM
It works! Thank you John!!


08-12-2011, 09:25 AM
Formally i am using tabcontent.js form your dynamic drive.but it is better than that .(i know blogger does not support php).:confused:

Is there any way to use this script in blogger ???

If it possible! if yes please help me show the category instant of showing single image