Sublime directory Surf the web anonymous Pagerank Monitor


Photo Album Problem

PHPNewbie-KY
Sat 2 June 2007, 03:37 am GMT +0300
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 
;
  
$row ;
for (
$i=0$i<sizeof($files); $i++) // output each element from the array
{
$picture $picture ;
echo 
"<td width=\"100\"><a href=\"album1.php?P=$i\"><img src=\"resize.php?$files[$i]\" border=\"0\" alt=\"\"></a></td>";
if(
$picture == )
{
?>

  </tr>
        <tr>
         
  <?php
$row 
;
$picture ;
  }
}
?>

        </tr>
      </table></div>
<?php
}
else
{
$i $photo ;
?>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><div align="center"><a href="/photos.php">Back to Photos Page</a></div></td>
        </tr>
        <tr>
          <td><div align="center"><img src="<?php echo"resize2.php?$files[$i]";?>" alt=""></div></td>
        </tr>
        <tr>
          <td><div align="center"><a href="images/gallery/<?php echo"$files[$i]";?>" target="_blank">Show fullscreen</a></div></td>
        </tr>

      </table>
  <table width="50%" border="0" cellspacing="0" cellpadding="0" style="margin-left: 25%; margin-right: 25%; ">
        <tr>
          <td>
  <?php 
  $i 
$i 1
  if(
$i >= 0)
   {
   echo 
"<a href=\"album1.php?P=$i\"><img src=\"resize.php?$files[$i]\" border=\"0\" alt=\"\"></a>"
}
  
?>

  </td>
          <td>
  <?php 
  $i 
$i 2
  if(
$i sizeof($files))
   {
echo 
"<a href=\"album1.php?P=$i\"><img src=\"resize.php?$files[$i]\" border=\"0\" align=\"right\" alt=\"\"></a>"
}
?>
</td>
        </tr>
<tr>
  <td>
  <?php 
  
if($i >= )
   {
echo
"Previous Image"
}
?>
</td>
  <td><div align="right">
  <?php
  
if($i sizeof($files))
   {
echo
"Next Image";
}
?>

</div></td>
</tr>
      </table>

<?php

}
?>

     

any help would be appreciated!
Thanks

Nikolas
Sat 2 June 2007, 03:50 am GMT +0300
Is this page live somewhere?

What is the problem that you have?

PHPNewbie-KY
Sat 2 June 2007, 04:20 am GMT +0300
It is live.  I will PM you the link.

It is not loading the pictures.  Little boxes come up but then they disappear. 

PHPNewbie-KY
Sat 2 June 2007, 04:40 pm GMT +0300
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....

PHPNewbie-KY
Thu 7 June 2007, 04:04 pm GMT +0300
Does no one have any idea what it might be?  I have trouble shot everything I can think of.....

Nikolas
Thu 7 June 2007, 05:02 pm GMT +0300
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.

PHPNewbie-KY
Thu 7 June 2007, 05:19 pm GMT +0300
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.

PHPNewbie-KY
Thu 7 June 2007, 05:28 pm GMT +0300
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.

olaf
Thu 7 June 2007, 05:30 pm GMT +0300
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

PHPNewbie-KY
Thu 7 June 2007, 05:33 pm GMT +0300
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!

redredred
Fri 20 July 2007, 01:29 am GMT +0300
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.

Archive for SMF v1.00 by N.P. Valid XHTML 1.0 Transitional