Random/latest images code causing max_user_connections issues (NOT cpmFetch) Random/latest images code causing max_user_connections issues (NOT cpmFetch)
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Random/latest images code causing max_user_connections issues (NOT cpmFetch)

Started by dagresham, April 28, 2007, 02:07:13 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

dagresham

Hi,

I have some code in my theme.php to extract random/latest image data for use in my layout.  It's for a high traffic website with limited resources, but it runs the existing unmodified system fine.  My code is:


    $randoms = 2;
    for($i=0; $i < $randoms; $i++){
      $image = get_pic_data('random', $count, $album_name, 0, 1, false);
      $image = current($image);
      $random_images .= "<a href=\"displayimage.php?album=".$image['aid']."&pos=-{$image['pid']} \">".
                     "<img src=\"" . get_pic_url($image, 'thumb') . "\" ".
                     "class=\"leftmenuimage\"\></a><br /><br />";
    }
   
    //Get some latest images
    $latest_images = "";
    $latests = 2;
    $images = get_pic_data('lastup', $count, $album_name, 0, $latests, false);
    for($i=0; $i < $latests; $i++){
      $image = $images[$i];
      $latest_images .= "<a href=\"displayimage.php?album=".$image['aid']."&pos=-{$image['pid']} \">".
                     "<img src=\"" . get_pic_url($image, 'thumb') . "\" ".
                     "class=\"leftmenuimage\"\></a><br /><br />";
    }


I then pass $random_images and $latest_images as {RANDOM_IMAGES} and {LATEST_IMAGES} to the template parser.  All is well on the test system, but when I put it live it crashes the database with the max_user_connections issue.  Any idea what could be causing it?  It's my understanding that this code shouldn't require any more database connections than before (and just so nobody suggests it, I was using cpmFetch but it caused exactly the same problem).

I'd probably get into trouble for dumping the whole phpinfo here, although I can get it if people think it might be relevant.  max_user_connections is currently 64 and won't be raised due to cost issues.

Thanks,

Douglas

Nibbler

I can't see how that code is supposed to cause that error. It's probably caused by some other modification. Have you modified get_pic_url() atall? Can you post a link?