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

  • Home
  • SEARCH
  • 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 325973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:15:59+00:00 2026-05-12T09:15:59+00:00

I currently have a script which will pull in image contents from a database

  • 0

I currently have a script which will pull in image contents from a database and, using createimagefromstring(), returns a resized (resampled) image for display:

$max_width = 170;

// Get the image

@mysql_connect('host', 'user', 'pass');
@mysql_select_db('db');

$query = "SELECT `thumbnail_contents`, `thumbnail_mimetype` FROM `videos` WHERE video_number  = '$video_number'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_object($result);

// Resize if pic bigger than $max_width
// Set the header
header('Content-type:' . $row->thumbnail_mimetype);

// Get original size of image
$image = imagecreatefromstring($row->thumbnail_contents);
$current_width = imagesx($image);
$current_height = imagesy($image);

// Set thumbnail width
$widths = array($current_width, $max_width);
$new_width = min($widths);

// Calculate thumbnail height from given width to maintain ratio
$new_height = $current_height / $current_width*$new_width;

// Create new image using thumbnail sizes
$thumb = imagecreatetruecolor($new_width,$new_height);

// Copy original image to thumbnail
imagecopyresampled($thumb,$image,0,0,0,0,$new_width,$new_height,imagesx($image),imagesy($image));

// Show thumbnail on screen
$show = imagejpeg($thumb);

// Clean memory
imagedestroy($image);
imagedestroy($thumb);

Currently, this script works for most thumbnails and shows them on-screen as desired. However, when I upload an image with a high width, say over 1000px, it gets stored in the database, but the script doesn’t show the resampled image.

To troubleshoot, I’ve checked the db, as well as print_r’d the output from the query. Everything seems to be kosher… Could someone tell me what might be causing such behavior? Any help or guidance is greatly appreciated!

  • 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-12T09:16:00+00:00Added an answer on May 12, 2026 at 9:16 am

    $5 says php is running out of memory. Check your php error logs.

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

Sidebar

Ask A Question

Stats

  • Questions 193k
  • Answers 193k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You are dealing with a bug in GCC compiler. C++… May 12, 2026 at 6:31 pm
  • Editorial Team
    Editorial Team added an answer Since you can't reference the project you will have to… May 12, 2026 at 6:31 pm
  • Editorial Team
    Editorial Team added an answer First, in your WHERE clause, you should replace this: --… May 12, 2026 at 6:31 pm

Related Questions

I have put together a script which is very much like the flickr photostream
I've been trying to somehow get my javascript function (which I have in the
If I have a greenfield project, what is the best practice Perl based configuration
I come from a CVS background. I'm currently investigating using SVN for a project.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.