Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7398655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:53:50+00:00 2026-05-29T03:53:50+00:00

I have some images in a mysql database stored as BLOB’s. The maximum file

  • 0

I have some images in a mysql database stored as BLOB’s.

The maximum file size of the images is 5MB.

I am trying to create thumbnails of the images, using php GD.

I am using the script below:

include 'models/connectdb.php';

// ------ starting up ------ //

$directory = 'views/images/generated/events/xs/';
$table = 'events';
$dimension_x = 50;
$dimension_y = 50;


// ------- proccess ------- //

//$query = "ALTER TABLE $table ADD thumb0 VARCHAR(100);";
//$result = mysql_query($query) or die(mysql_error());
$query = "SELECT * FROM $table;";
$result = mysql_query( $query ) or die(mysql_error());
while( $row = mysql_fetch_array( $result ) ) {
    $id = $row['id'];
    $uploaded_image = base64_decode( $row['image'] );
    $uploaded_image = imagecreatefromstring( $uploaded_image );
    $uploaded_x = imagesx($uploaded_image);
    $uploaded_y = imagesy($uploaded_image);
    do{
       $filename = random_32();
       $filename = $directory.$filename.'.jpg'; 
    } while( file_exists($filename) );
       $thumb = imagecreatetruecolor( $dimension_x , $dimension_y );
       imagecopyresampled( $thumb , $uploaded_image , 0 , 0 , 0 , 0 , $dimension_x , $dimension_y , $uploaded_x, $uploaded_y);
       imagedestroy( $uploaded_image ); // I also tried unset( $uploaded_image );
       imagejpeg( $thumb , $filename , 90);
       $query = "UPDATE $table SET image_xs = '$filename' WHERE id = $id LIMIT 1;";
       mysql_query($query) or die(mysql_error());
       echo "ran for one , ";
    }
echo "it all ran";

function random_32() { // this function generates a random filename
    $filename = rand( 100000000000000000 , 999999999999999999 );
    $filename = md5( $filename );
    return $filename;
    }

What I am getting is:

ran for one ,
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 14032 bytes) in /home/leagu11/public_html/nightscene.gr/create_thumbs_people.php on line 21

Meaning my script runs for one image and dies before running for the next one.

I think I am doing something wrong with unsetting / destroying my data after each loop execution.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T03:53:51+00:00Added an answer on May 29, 2026 at 3:53 am

    You could ini_set the allowed memory size for the runtime of the current script using ini_set('memory_limit','128M'); But i have a feeling there might be something deeper hiding there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an image file which is stored onto database as a blob (shown
i have the following code that generate some images with urls associated from database:
I have to extract some product information from mysql database, then construct a SOAP
I have a JavaScript slideshow that pre-loads images out of a MySQL database and
Instead of storing images using BLOB in mySQL, I have decided to attempt to
I have a folder of images and a MySQL database to manage them. The
Currently I created mySQL database with the reference path of images and some additional
I have some images that need to change, based not only on hover, but
a I have some images on page and I want to put <span> tag
I'm tinkering with Silverlight 2.0. I have some images, which I currently have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.