Supreme Overlord
Gender:
Posts: 148
1008 credits Members referred : 0
« on: Jun 02, 2007, 03:37:17 AM »
I have several php photo albums on my site. They all work fine, and follow the same code, the only difference is the name and directory. I have a new album I am trying to incorporate. And it won't work. All I changed is the directory and some other file names. The only difference is that the new pictures have some panoramic pictures.
Code:
<?php $photo = $_GET['P'];
$dirlist = "images/ablum1/"; // leave it alone if it's the same directory // Change it if you want to view a different // directory. default value: "./"
if (is_dir($dirlist)==true ) // check if directory exists { chdir( $dirlist ); $handle=opendir( "."); // open the directory $x=0; $files=array(); while (($file = readdir($handle))!==false) // while there's files to read.... { $pieces = explode (".", $file); if ($pieces[0] && $pieces[1]) // filename.ext { // if (($pieces[1]=="jpg")) // add only .jpg files // { $files[$x]=$file; // add it to the array. $x++; // } } } } closedir($handle); //done finding files
sort($files); // sort them alphabetically if ($photo == '') { ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <?php $picture = 0 ; $row = 1 ; for ($i=0; $i<sizeof($files); $i++) // output each element from the array { $picture = $picture + 1 ; echo "<td width=\"100\"><a href=\"album1.php?P=$i\"><img src=\"resize.php?$files[$i]\" border=\"0\" alt=\"\"></a></td>"; if($picture == 4 ) {?> </tr> <tr>
Supreme Overlord
Gender:
Posts: 148
1008 credits Members referred : 0
« Reply #2 on: Jun 02, 2007, 04:20:37 AM »
It is live. I will PM you the link.
It is not loading the pictures. Little boxes come up but then they disappear.
Supreme Overlord
Gender:
Posts: 148
1008 credits Members referred : 0
« Reply #3 on: Jun 02, 2007, 04:40:22 PM »
Also, if you put in the address to take you to the pages, /album1.php?P=5 the pictures still aren't there, but if you click on show full screen it will take you to just the picture on the page....
Supreme Overlord
Gender:
Posts: 148
1008 credits Members referred : 0
« Reply #4 on: Jun 07, 2007, 04:04:51 PM »
Does no one have any idea what it might be? I have trouble shot everything I can think of.....
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 8037
41179 credits Members referred : 3
« Reply #5 on: Jun 07, 2007, 05:02:47 PM »
I just took a look to your script and it looks very bad coded.
The problem is probably in the resize2.php, not the script you posted. Check the directories if they are correct.
Supreme Overlord
Gender:
Posts: 148
1008 credits Members referred : 0
« Reply #6 on: Jun 07, 2007, 05:19:08 PM »
I have checked the directory. I am looking into the resize issue. I think you might be right & that is it.
That is a code I got from someone else & made some changes. For learning reasons can you tell me why it's bad? I would like to know so I can fix the mistakes & not do it again.
BTW - that is not the code for the entire page, but just what I thought was relative to this discussion.
Supreme Overlord
Gender:
Posts: 148
1008 credits Members referred : 0
« Reply #7 on: Jun 07, 2007, 05:28:44 PM »
It's fixed!
BTW - I know that goodlady is watching this post & this site. Since you seem SO interested in this album & trying to hit it there will be a link to it from my camping page in a few minutes.
« Last Edit: Jun 08, 2007, 02:07:11 PM by PHPNewbie-KY »
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6309
38674 credits Members referred : 374
It's time to use PHP5!
« Reply #8 on: Jun 07, 2007, 05:30:33 PM »
within this code there are too much php code jump in and outs, this way your server has much more to work, Check the net for articles about separating php code and html
Supreme Overlord
Gender:
Posts: 148
1008 credits Members referred : 0
« Reply #9 on: Jun 07, 2007, 05:33:00 PM »
OK, thanks. Do you think that might be b/c I only put part of the code up? I am going to look into that though, I want my pages to load faster! Thanks for your help!
Where are my glasses?
Posts: 21
138 credits Members referred : 0
« Reply #10 on: Jul 20, 2007, 01:29:22 AM »
I would separate the code from the design. A good way to do so is to use a template engine. Because the page doesn't change very often, you could cache the generated content. I can recommend HSTemplate: You can use PHP in your plugins and don't have to write pseudo code like it is in Smarty. HSTemplate is much faster than Smarty and many other template engines because the file is being incldued.
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6693