Jump to content

Recommended Posts

I can't seem to find the loop that's eating up the memory. If anyone else can spot it . . . PLEASE . . .let me know.

 

The Error:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 33292335 bytes) in /home/styles/public_html/photosview.php on line 63

 

And the actual code:

<?php
//Checking for completion of thumb nail outputs
while ($ThumbOutPut == 0) {

//checking for existence of file
  while ($FileExists == 0) {
    $ThumbTest = 'galleries/' . $Directory . '/small/small_' . $Suffix . $ImageNumber . '.' . $Extension;
    if (file_exists($ThumbTest)) {
      $FileExists = 1;
    } else {
      $ImageNumber++;
    }
  }
  $FileExists = 0;

//checks to see if this is the last image or not  
  if ($ImageNumber == $LImage) {
    $ThumbOutPut = 1;
  } else {
  
//checks to see if there are <td> elements yet and creates a new row
    if ($ThumbLineCounter == 5) {
      $ThumbNails .=<<<EOD
        </tr>
        
        <tr>
EOD;
      $ThumbLineCounter = 0;
    }
    
    $ThumbNails .=<<<EOD
      <td valign="top" align="center">
        <img src="$ThumbTest" border="0">
      </td>

//The EOD; Right after this is line 63
EOD;
    $ThumbLineCounter++;
  }
}
?>

 

If you guys notice anything . . . please point it out.

It's only 48 items . . . this is to populate a photo gallery.

 

A step by step:

 

1.) Runs a loop to keep cycling through the images based on the number of the image. (while ($ThumbOutPut == 0))

2.) Runs a loop to see if the file exists (while ($FileExists == 0 ))

3.) If the file is found, it sets $FileExists to 1 continues . . . then resets $FileExists for the next round. If it doesn't, it increases $ImageNumber and repeats

4.) Then, it checks to see if $ImageNumber is equal to $LImage which would mean that the program has found the last image. It sets $ThumbOutPut to 1 which should end the entire loop. If it hasn't, it continues with the code:

5.) It Then checks to see if there have been 5 images output in one row ($ThumbLineCounter). If it has, it creates a new row in the table, otherwise it creates a new column and outputs the image. Then increases $ThumbLineCounter by 1.

 

I'll try it with like 2 images or something and see what happens.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.